edited categories and added translations

This commit is contained in:
Laura Dolibois
2025-05-25 15:18:08 +02:00
parent 419554748f
commit 893ee1873a
5 changed files with 101 additions and 48 deletions

View File

@@ -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
)
}
/>