2023-09-12 11:53:12 +02:00
|
|
|
import { useState } from 'react'
|
2023-09-05 17:31:22 +02:00
|
|
|
import q from 'qjuul'
|
2023-09-12 11:53:12 +02:00
|
|
|
import { useNavigateToPage } from '../../util/navigate'
|
2023-09-05 17:31:22 +02:00
|
|
|
|
2023-09-12 11:53:12 +02:00
|
|
|
const MovieForm: React.FC = () => {
|
|
|
|
const [movieTitle, setMovieTitle] = useState('')
|
|
|
|
const [movieYear, setMovieYear] = useState('')
|
|
|
|
const [movieType, setMovieType] = useState('')
|
|
|
|
const navigateToPage = useNavigateToPage()
|
2023-09-05 17:31:22 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<q.form
|
2023-09-06 06:58:41 +02:00
|
|
|
className="flex flex-col gap-3 card p-4 rounded-lg w-full lg:px-14"
|
2023-09-12 11:53:12 +02:00
|
|
|
onSubmit={() => navigateToPage(movieTitle, movieYear, movieType)}
|
2023-09-05 17:31:22 +02:00
|
|
|
>
|
|
|
|
<q.label>Choose a movie title:</q.label>
|
|
|
|
<q.input
|
|
|
|
type="text"
|
|
|
|
id="movieTitle"
|
|
|
|
placeholder="Movie title"
|
|
|
|
onChange={(e) => setMovieTitle(e.target.value)}
|
2023-09-06 11:14:50 +02:00
|
|
|
className="border text-black border-gray-300 rounded-md p-2 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent"
|
2023-09-05 17:31:22 +02:00
|
|
|
/>
|
|
|
|
<q.label>Choose year movie was made: (OPTIONAL)</q.label>
|
|
|
|
<q.select
|
2023-09-06 11:14:50 +02:00
|
|
|
className="p-2 rounded-md border text-gray-500 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent"
|
2023-09-05 17:31:22 +02:00
|
|
|
onChange={(e) => setMovieYear(e.target.value)}
|
|
|
|
>
|
|
|
|
{/* Option for year 1923-2023 */}
|
|
|
|
<q.option value="">All years</q.option>
|
|
|
|
{Array.from(Array(100), (e, i) => {
|
|
|
|
const year = 2023 - i
|
|
|
|
return (
|
|
|
|
<q.option key={i} value={year}>
|
|
|
|
{year}
|
|
|
|
</q.option>
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
</q.select>
|
|
|
|
<q.label>Choose type: (OPTIONAL)</q.label>
|
|
|
|
<q.select
|
2023-09-06 11:14:50 +02:00
|
|
|
className="p-2 rounded-md border text-gray-500 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent"
|
2023-09-05 17:31:22 +02:00
|
|
|
onChange={(e) => setMovieType(e.target.value)}
|
|
|
|
>
|
|
|
|
<q.option value="">All types</q.option>
|
|
|
|
<q.option value="movie">Movies</q.option>
|
|
|
|
<q.option value="series">Series</q.option>
|
|
|
|
<q.option value="episode">Episodes</q.option>
|
|
|
|
</q.select>
|
2023-09-06 06:58:41 +02:00
|
|
|
<q.button className="bg-white p-3 my-2 rounded-md w-3/5 md:w-2/5 mx-auto text-red-900 font-semibold">
|
2023-09-05 17:31:22 +02:00
|
|
|
Find movies
|
|
|
|
</q.button>
|
|
|
|
</q.form>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MovieForm
|