import { useContext } from "react";
import { ProgressBarContext, ProgressBarUnit } from "./ProgressBarProvider";

type UseProgressBarResult = {
  progress: boolean;
  observe: (unit?: ProgressBarUnit | ProgressBarUnit[]) => void;
};

const useProgressBar = (): UseProgressBarResult => {
  const context = useContext(ProgressBarContext);
  return { progress: context.progress, observe: context.actions.observe };
};

export { useProgressBar };
