added sound context, and functionality to select sighting sound
This commit is contained in:
@@ -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 }) => (
|
||||
|
||||
Reference in New Issue
Block a user