edited categories and added translations
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import { FormControl, FormControlLabel, Radio, RadioGroup, Rating } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
type FilterItemOption = {
|
||||
value: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
type FilterItemProps = {
|
||||
filterName: string;
|
||||
filterItems: any[];
|
||||
filterItems: FilterItemOption[];
|
||||
value?: string | null;
|
||||
onChange?: (value: string) => void;
|
||||
};
|
||||
@@ -14,12 +19,14 @@ export default function FilterItem({
|
||||
value,
|
||||
onChange
|
||||
}: FilterItemProps) {
|
||||
if(!value) {
|
||||
value = filterItems[0];
|
||||
if (!value && filterItems.length > 0) {
|
||||
value = filterItems[0].value;
|
||||
}
|
||||
|
||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
value = (event.target.value);
|
||||
if (onChange) {
|
||||
onChange(event.target.value);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -30,13 +37,13 @@ export default function FilterItem({
|
||||
{filterItems.map((item, idx) => (
|
||||
<FormControlLabel
|
||||
key={idx}
|
||||
value={item}
|
||||
value={item.value}
|
||||
control={<Radio />}
|
||||
label={
|
||||
filterName === "Rating" ? (
|
||||
<Rating readOnly value={Number(item)} precision={1} size="small" />
|
||||
/^[1-5]$/.test(item.value) ? (
|
||||
<Rating readOnly value={Number(item.value)} precision={1} size="small" />
|
||||
) : (
|
||||
item
|
||||
item.label
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user