fix: missing id/name on custom select input

This commit is contained in:
enes 2024-08-06 14:07:41 +02:00
parent e4a7fa4892
commit d0e3704ed6
2 changed files with 9 additions and 1 deletions

View File

@ -62,11 +62,15 @@ interface SelectItemProps<T extends string> {
interface SelectProps<T extends string> { interface SelectProps<T extends string> {
setValue: React.Dispatch<React.SetStateAction<T>> setValue: React.Dispatch<React.SetStateAction<T>>
options: SelectItemProps<T>[] options: SelectItemProps<T>[]
name?: string
id?: string
} }
export function Select<T extends string>({ export function Select<T extends string>({
setValue, setValue,
options options,
name,
id
}: SelectProps<T>) { }: SelectProps<T>) {
const handleChange = (event: SelectChangeEvent<unknown>) => { const handleChange = (event: SelectChangeEvent<unknown>) => {
setValue(event.target.value as T) setValue(event.target.value as T)
@ -75,6 +79,8 @@ export function Select<T extends string>({
return ( return (
<FormControl> <FormControl>
<SelectCustomized <SelectCustomized
id={id}
name={name}
size="small" size="small"
variant="outlined" variant="outlined"
defaultValue={options[0].value as string} defaultValue={options[0].value as string}

View File

@ -109,6 +109,7 @@ export const HomePage = () => {
{isFilterVisible && ( {isFilterVisible && (
<> <>
<Select <Select
name={'filter-select'}
setValue={setFilter} setValue={setFilter}
options={FILTERS.map((f) => { options={FILTERS.map((f) => {
return { return {
@ -118,6 +119,7 @@ export const HomePage = () => {
})} })}
/> />
<Select <Select
name={'sort-select'}
setValue={setSort} setValue={setSort}
options={SORT_BY.map((s) => { options={SORT_BY.map((s) => {
return { ...s } return { ...s }