import { Field, FieldArray, Form, Formik } from "formik"; import FormGroup from "../components/FormGroup"; import type { FormValues, Hotlist } from "../../../types/types"; import { useSoundContext } from "../../../context/SoundContext"; import { toast } from "sonner"; const SoundSettingsFields = () => { const { state, dispatch } = useSoundContext(); const hotlists: Hotlist[] = [ { name: "hotlist0", sound: "" }, { name: "hotlist1", sound: "" }, { name: "hotlist2", sound: "" }, ]; const soundOptions = state?.soundOptions?.map((soundOption) => ({ value: soundOption?.name, label: soundOption?.name, })); const initialValues: FormValues = { sightingSound: state.sightingSound ?? "switch", NPEDsound: state.NPEDsound ?? "popup", hotlists, }; const handleSubmit = (values: FormValues) => { dispatch({ type: "UPDATE", payload: values }); toast.success("Sound settings updated"); }; return ( {({ values }) => (
{soundOptions?.map(({ value, label }) => { return ( ); })} {soundOptions?.map(({ value, label }) => ( ))}

Hotlist Sounds

(
{values.hotlists.length > 0 ? ( values.hotlists.map((hotlist, index) => (
{soundOptions?.map(({ value, label }) => ( ))}
)) ) : (

No hotlists yet, Add one

)}
)} />
)}
); }; export default SoundSettingsFields;