import {
  NavigationContextProps,
  NavigationProviderProps,
} from "@app/models/components";
import { createContext, useContext, useState } from "react";

const NavigationContext = createContext<NavigationContextProps>(
  {} as NavigationContextProps
);
export const NavigationProvider: React.FC<NavigationProviderProps> = ({
  children,
}) => {
  const [isNavBlocked, setIsNavBlocked] = useState<boolean>(false);

  return (
    <NavigationContext.Provider
      value={{
        isNavBlocked,
        setIsNavBlocked,
      }}
    >
      {children}
    </NavigationContext.Provider>
  );
};

export const useBlockNavigation = () => {
  return useContext(NavigationContext);
};
