added sound context, and functionality to select sighting sound

This commit is contained in:
2025-09-30 14:51:37 +01:00
parent 673df1a4f4
commit 2aeae761f8
9 changed files with 109 additions and 86 deletions

View File

@@ -1,8 +1,10 @@
import { Field, FieldArray, Form, Formik } from "formik";
import FormGroup from "../components/FormGroup";
import type { FormValues, Hotlist } from "../../../types/types";
import { useSoundContext } from "../../../context/SoundContext";
const SoundSettingsFields = () => {
const { state, dispatch } = useSoundContext();
const hotlists: Hotlist[] = [
{ name: "hotlist0", sound: "" },
{ name: "hotlist1", sound: "" },
@@ -25,15 +27,15 @@ const SoundSettingsFields = () => {
];
const initialValues: FormValues = {
sightingSound: "switch",
NPEDsound: "popup",
sightingSound: state.sightingSound ?? "switch",
NPEDsound: state.NPEDsound ?? "popup",
hotlists,
};
const handleSubmit = (values: FormValues) => {
console.log(values);
dispatch({ type: "UPDATE", payload: values });
};
console.log(state);
return (
<Formik initialValues={initialValues} onSubmit={handleSubmit}>
{({ values }) => (