import { createContext, useContext, useState } from "react";

export const LanguageContext = createContext({
	language: "fr",
	changeLanguage: () => {},
});

export function LanguageContextProvider({ children }) {
	const [language, setLanguage] = useState("fr");

	function changeLanguage() {
		if (language === "fr") {
			setLanguage("en");
		} else {
			setLanguage("fr");
		}
	}
	return <LanguageContext.Provider value={{ language, changeLanguage }}>{children}</LanguageContext.Provider>;
}

export function useLanguage() {
	return useContext(LanguageContext);
}
