import type { SoundAction, SoundState } from "../../types/types"; export const initialState: SoundState = { sightingSound: "switch", NPEDsound: "popup", hotlists: [{ name: "hotlistName", sound: "notification" }], soundOptions: [ { name: "switch (Default)", soundFile: null }, { name: "popup", soundFile: null }, { name: "notification", soundFile: null }, ], }; export function reducer(state: SoundState, action: SoundAction): SoundState { switch (action.type) { case "UPDATE": { return { ...state, sightingSound: action.payload.sightingSound, NPEDsound: action.payload.NPEDsound, hotlists: action.payload.hotlists?.map((hotlist) => ({ name: hotlist.name, sound: hotlist.sound, })), }; } case "ADD": { return { ...state, soundOptions: [...(state.soundOptions ?? []), action.payload], }; } default: return state; } }