import { Field, Form, Formik } from "formik"; import FormGroup from "../components/FormGroup"; import type { FormValues, Hotlist } from "../../../types/types"; import { useSoundContext } from "../../../context/SoundContext"; import { useCameraBlackboard } from "../../../hooks/useCameraBlackboard"; import { toast } from "sonner"; import SliderComponent from "../../UI/Slider"; const SoundSettingsFields = () => { const { state, dispatch } = useSoundContext(); const { mutation } = useCameraBlackboard(); const hotlists: Hotlist[] = state.hotlists; const soundOptions = state?.soundOptions?.map((soundOption) => ({ value: soundOption?.soundFileName, label: soundOption?.name, })); const initialValues: FormValues = { sightingSound: state.sightingSound ?? "switch", NPEDsound: state.NPEDsound ?? "popup", hotlistSound: state.hotlistSound ?? "notification", hotlists, }; const handleSubmit = async (values: FormValues) => { const updatedValues = { ...values, sightingVolume: state.sightingVolume, NPEDsoundVolume: state.NPEDsoundVolume, hotlistSoundVolume: state.hotlistSoundVolume, }; dispatch({ type: "UPDATE", payload: updatedValues }); const result = await mutation.mutateAsync({ operation: "INSERT", path: "soundSettings", value: updatedValues, }); if (result.reason !== "OK") { toast.error("Cannot update sound settings"); } else { toast.success("Sound Settings successfully updated"); } }; return ( {() => (
{soundOptions?.map(({ value, label }) => { return ( ); })}
{soundOptions?.map(({ value, label }) => ( ))}

Hotlist Sounds

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

No hotlists yet, Add one

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