import { useReducer, type ReactNode } from "react";
import { SoundContext } from "../SoundContext";
import { initalState, reducer } from "../reducers/SoundContextReducer";

type SoundContextProviderProps = {
  children: ReactNode;
};

const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
  const [state, dispatch] = useReducer(reducer, initalState);
  return (
    <SoundContext.Provider value={{ state, dispatch }}>
      {children}
    </SoundContext.Provider>
  );
};

export default SoundContextProvider;
