import { PropsWithChildren, useState } from "react";

import { LoadingContext } from "../model/LoadingContext";

import { LoadIndicator } from "./LoadIndicator";

export function LoadingContextProvider({ children }: PropsWithChildren) {
	const [isLoading, setIsLoading] = useState(false);

	return (
		<LoadingContext.Provider value={{ isLoading, setIsLoading }}>
			{children}

			{isLoading && <LoadIndicator />}
		</LoadingContext.Provider>
	);
}
