GeneIT/geneit_app/src/widgets/forms/SexSelection.tsx
Pierre HUBERT cd7462ffb1
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
Refactor API routes
2024-05-15 18:27:48 +02:00

45 lines
1.0 KiB
TypeScript

import {
FormControl,
FormLabel,
RadioGroup,
FormControlLabel,
Radio,
Typography,
} from "@mui/material";
import { Sex } from "../../api/genealogy/MemberApi";
export function SexSelection(p: {
readonly?: boolean;
current?: Sex;
onChange: (s: Sex) => void;
}): React.ReactElement {
if (p.readonly) {
if (p.current === undefined || p.current === null) return <></>;
return (
<Typography
variant="body2"
display="block"
style={{ marginBottom: "15px" }}
>
Sexe : {p.current === "M" ? "Homme" : "Femme"}
</Typography>
);
}
return (
<FormControl style={{ marginBottom: "15px" }}>
<FormLabel id="sex-label">Sexe</FormLabel>
<RadioGroup
row
aria-labelledby="sex-label"
value={p.current}
onChange={(e) => p.onChange(e.target.value as Sex)}
>
<FormControlLabel value="M" control={<Radio />} label="Homme" />
<FormControlLabel value="F" control={<Radio />} label="Femme" />
</RadioGroup>
</FormControl>
);
}