2021-07-14 00:31:37 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { Arrow } from './Arrow';
|
|
|
|
import './InputBox.css'
|
|
|
|
|
|
|
|
// props = { onSubmit: (str) => {}, placeholder: string}
|
|
|
|
export function InputBox({ onSubmit, placeholder }) {
|
2021-07-14 17:15:25 +02:00
|
|
|
const [searchTerm, setSearchTerm] = React.useState("");
|
|
|
|
const [type, setType] = React.useState("movie");
|
|
|
|
|
|
|
|
const showContentType = type === "show" ? false : true;
|
2021-07-14 00:31:37 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<form className="inputBar" onSubmit={(e) => {
|
|
|
|
e.preventDefault();
|
2021-07-14 17:15:25 +02:00
|
|
|
onSubmit(searchTerm, type)
|
2021-07-14 00:31:37 +02:00
|
|
|
return false;
|
|
|
|
}}>
|
2021-07-14 17:15:25 +02:00
|
|
|
<select name="type" id="type" className="inputDropdown" onChange={(e) => setType(e.target.value)} required>
|
|
|
|
<option value="movie">Movie</option>
|
|
|
|
<option value="show">TV Show</option>
|
|
|
|
</select>
|
2021-07-14 00:31:37 +02:00
|
|
|
<input
|
|
|
|
type='text'
|
|
|
|
className="inputTextBox"
|
|
|
|
id="inputTextBox"
|
|
|
|
placeholder={placeholder}
|
2021-07-14 17:15:25 +02:00
|
|
|
value={searchTerm}
|
|
|
|
onChange={(e) => setSearchTerm(e.target.value)}
|
|
|
|
required
|
2021-07-14 00:31:37 +02:00
|
|
|
/>
|
2021-07-14 17:15:25 +02:00
|
|
|
<input type='text' className='inputOptionBox' id='inputOptionBoxSeason' placeholder='s' required={showContentType} hidden={showContentType}/>
|
|
|
|
<input type='text' className='inputOptionBox' id='inputOptionBoxEpisode' placeholder='e' required={showContentType} hidden={showContentType}/>
|
|
|
|
<button className="inputSearchButton"><span className="text">Search<span className="arrow"><Arrow /></span></span></button>
|
2021-07-14 00:31:37 +02:00
|
|
|
</form>
|
|
|
|
)
|
|
|
|
}
|