Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 29x 19x 19x 38x 19x | import { Box } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { useFormContext } from "react-hook-form";
export const ClearSectionButton = ({
names,
label = "Clear",
onClear,
}: {
names: string[];
label?: string;
onClear?: (clearedNames: string[]) => void;
}) => {
const methods = useFormContext();
const values = methods.watch();
const isUsed = names.some((name) => typeof values[name] === "boolean");
Eif (!isUsed) return null;
return (
<Box height="20px">
<GiveText
onClick={() => {
names.forEach((name) => methods.setValue(name, undefined));
onClear && onClear(names);
}}
color="error1"
variant="bodyS"
sx={{
cursor: "pointer",
}}
>
{label}
</GiveText>
</Box>
);
};
|