import { Controller, useFormContext, type FieldPath, type FieldValues, } from "react-hook-form"; import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; import { useTheme } from "@mui/material/styles"; import { SwitchComponent } from "@/Components/inputs"; import { SPACING } from "@/Utils/Theme/constants"; interface FormSwitchProps { name: FieldPath; label: string; labelPlacement?: "start" | "end"; // left | right } export const FormSwitchField = ({ name, label, labelPlacement = "end", }: FormSwitchProps) => { const { control } = useFormContext(); const theme = useTheme(); return ( ( {labelPlacement === "start" ? ( <> {label} field.onChange(e.target.checked)} /> ) : ( <> field.onChange(e.target.checked)} /> {label} )} )} /> ); };