import { ThemeProvider, createTheme } from "@mui/material/styles"; import React from "react"; import { PropsWithChildren } from "react"; import { frFR as dataGridFr } from "@mui/x-data-grid"; const localStorageKey = "dark-theme"; const darkTheme = createTheme( { palette: { mode: "dark", }, }, dataGridFr ); const lightTheme = createTheme( { palette: { mode: "light", }, }, dataGridFr ); interface DarkThemeContext { enabled: boolean; setEnabled: (enabled: boolean) => void; } const DarkThemeContextK = React.createContext(null); export function DarkThemeProvider(p: PropsWithChildren): React.ReactElement { const [enabled, setEnabled] = React.useState( localStorage.getItem(localStorageKey) === "true" ); return ( {p.children} ); } export function useDarkTheme(): DarkThemeContext { return React.useContext(DarkThemeContextK)!; }