✨ Working form submission with query params
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
cd63407d03
commit
20aaef67d7
3 changed files with 7 additions and 2 deletions
|
@ -36,7 +36,7 @@ function App() {
|
||||||
} else {
|
} else {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}, [])
|
}, [location.search])
|
||||||
|
|
||||||
const calculatePages = (totalResults: number): number => {
|
const calculatePages = (totalResults: number): number => {
|
||||||
return Math.round(totalResults / 10)
|
return Math.round(totalResults / 10)
|
||||||
|
|
|
@ -11,7 +11,10 @@ const MovieForm: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<q.form
|
<q.form
|
||||||
className="flex flex-col gap-3 card p-4 rounded-lg w-full lg:px-14"
|
className="flex flex-col gap-3 card p-4 rounded-lg w-full lg:px-14"
|
||||||
onSubmit={() => navigateToPage(movieTitle, movieYear, movieType)}
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
navigateToPage(movieTitle, movieYear, movieType)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<q.label>Choose a movie title:</q.label>
|
<q.label>Choose a movie title:</q.label>
|
||||||
<q.input
|
<q.input
|
||||||
|
|
|
@ -11,6 +11,8 @@ export const useNavigateToPage = () => {
|
||||||
if (type) query += `&type=${type}`
|
if (type) query += `&type=${type}`
|
||||||
if (year) query += `&year=${year}`
|
if (year) query += `&year=${year}`
|
||||||
|
|
||||||
|
console.log(query)
|
||||||
|
|
||||||
navigate(query)
|
navigate(query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue