frontPanel/src/pages/PersonalizationAI/GenderAndAgeSelector.tsx

158 lines
4.9 KiB
TypeScript
Raw Normal View History

2025-06-08 17:52:55 +00:00
import { Box, FormControl, FormLabel, RadioGroup, FormControlLabel, Radio, useTheme, Button, useMediaQuery } from "@mui/material";
2025-05-25 13:21:19 +00:00
import CheckboxIcon from "@icons/Checkbox";
2025-06-03 17:27:14 +00:00
import AgeInputWithSelect from "./AgeInputWithSelect";
2025-05-25 13:21:19 +00:00
interface GenderAndAgeSelectorProps {
2025-06-08 17:52:55 +00:00
gender: string;
age: string;
ageError: boolean;
onGenderChange: (gender: string) => void;
onAgeChange: (age: string) => void;
onAgeErrorChange: (error: boolean) => void;
onStartCreate: () => void;
2025-05-25 13:21:19 +00:00
}
2025-06-08 17:52:55 +00:00
export default function GenderAndAgeSelector({
gender,
age,
ageError,
onGenderChange,
onAgeChange,
onAgeErrorChange,
onStartCreate
}: GenderAndAgeSelectorProps) {
2025-05-25 13:21:19 +00:00
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down(845));
2025-05-25 13:21:19 +00:00
2025-06-01 22:02:43 +00:00
return (
2025-06-02 15:53:46 +00:00
<Box sx={{ display: 'flex', gap: 4, alignItems: "end", flexWrap: "wrap" }}>
2025-06-03 17:27:14 +00:00
<Box sx={{ display: "inline-flex", flexWrap: isMobile ? "wrap" : "initial" }}>
2025-06-01 22:02:43 +00:00
<FormControl component="fieldset" variant="standard">
2025-06-02 15:53:46 +00:00
<Box sx={{ display: 'flex', alignItems: "end", gap: '4px' }}>
2025-06-01 22:02:43 +00:00
<FormLabel
sx={{
'&.Mui-focused': {
color: '#4D4D4D',
},
2025-05-25 13:21:19 +00:00
color: '#4D4D4D',
fontSize: '18px',
2025-06-01 22:02:43 +00:00
fontWeight: 500,
2025-05-25 13:21:19 +00:00
lineHeight: 1,
letterSpacing: 0,
2025-06-01 22:02:43 +00:00
mr: '3px',
}}
component="legend">Пол</FormLabel>
</Box>
<RadioGroup
2025-06-01 22:02:43 +00:00
sx={{
width: "155px",
justifyContent: "space-between",
2025-06-02 15:53:46 +00:00
mt: "20px",
2025-06-01 22:02:43 +00:00
ml: "-9px"
}}
row
aria-label="gender"
name="row-radio-buttons-group"
value={gender}
2025-06-08 17:52:55 +00:00
onChange={(e) => onGenderChange(e.target.value)}
2025-06-01 22:02:43 +00:00
>
<FormControlLabel
sx={{
padding: 0,
'& .MuiTouchRipple-root': {
width: '100%',
height: '100%',
overflow: 'visible',
},
'& .MuiSvgIcon-root': {
position: 'absolute',
left: '50%',
top: '50%',
transform: 'translate(-50%, -50%)',
},
'& .MuiFormControlLabel-label': {
fontSize: '18px',
fontWeight: 400,
fontFamily: 'Rubik',
lineHeight: 1,
letterSpacing: 0,
color: '#4D4D4D',
ml: "6px"
},
m: 0,
}}
value="male"
control={<Radio icon={<CheckboxIcon />} checkedIcon={<CheckboxIcon checked />} />}
2025-06-01 22:02:43 +00:00
label="М"
/>
<FormControlLabel
sx={{
padding: 0,
'& .MuiTouchRipple-root': {
width: '100%',
height: '100%',
overflow: 'visible',
},
'& .MuiSvgIcon-root': {
position: 'absolute',
left: '50%',
top: '50%',
transform: 'translate(-50%, -50%)',
},
'& .MuiFormControlLabel-label': {
fontSize: '18px',
fontWeight: 400,
fontFamily: 'Rubik',
lineHeight: 1,
letterSpacing: 0,
color: '#4D4D4D',
},
m: 0,
}}
value="female"
control={<Radio icon={<CheckboxIcon />} checkedIcon={<CheckboxIcon checked />} />}
2025-06-01 22:02:43 +00:00
label="Ж"
/>
</RadioGroup>
2025-06-01 22:02:43 +00:00
</FormControl>
2025-06-02 18:22:55 +00:00
<FormControl sx={{ maxWidth: "420px", width: "100%", marginLeft: isMobile ? "0" : "120px", minWidth: "265px" }} variant="filled">
2025-06-01 22:02:43 +00:00
<Box sx={{
display: 'flex',
2025-06-02 15:53:46 +00:00
alignItems: 'end',
2025-06-01 22:02:43 +00:00
gap: '4px'
}}>
<FormLabel sx={{
color: '#4D4D4D',
fontSize: "18px",
fontWeight: 500,
lineHeight: "100%",
'&.Mui-focused': {
2025-05-25 13:21:19 +00:00
color: '#4D4D4D',
},
2025-06-01 22:02:43 +00:00
}}>Возраст</FormLabel>
</Box>
2025-06-08 17:52:55 +00:00
<AgeInputWithSelect value={age} onChange={onAgeChange} onErrorChange={onAgeErrorChange} />
2025-06-01 22:02:43 +00:00
</FormControl>
</Box>
<Button
2025-06-08 17:52:55 +00:00
onClick={onStartCreate}
2025-06-01 22:02:43 +00:00
variant="contained"
disabled={!gender || !age || ageError}
2025-06-01 22:02:43 +00:00
sx={{
bgcolor: theme.palette.brightPurple.main,
borderRadius: "8px",
width: "130px",
height: "48px",
boxShadow: "none",
textTransform: "none",
fontSize: "18px",
'&:hover': { bgcolor: theme.palette.brightPurple.main },
}}
>
Ок
</Button>
2025-06-08 17:52:55 +00:00
</Box>
2025-05-25 13:21:19 +00:00
);
}