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

type AlertHitProviderTypeProps = {
  children: ReactNode;
};

export const AlertHitProvider = ({ children }: AlertHitProviderTypeProps) => {
  const [state, dispatch] = useReducer(reducer, initalState);

  return (
    <AlertHitContext.Provider value={{ state, dispatch }}>
      {children}
    </AlertHitContext.Provider>
  );
};

export default AlertHitProvider;
