chore: format project automatically before starting dev server
This commit is contained in:
@@ -51,13 +51,16 @@ export function AuthProvider({children}: {children: ReactNode}) {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const finishLogin = useCallback((next: AuthSession) => {
|
||||
persist(next);
|
||||
setLoginOpen(false);
|
||||
const callback = successCallback.current;
|
||||
successCallback.current = undefined;
|
||||
callback?.();
|
||||
}, [persist]);
|
||||
const finishLogin = useCallback(
|
||||
(next: AuthSession) => {
|
||||
persist(next);
|
||||
setLoginOpen(false);
|
||||
const callback = successCallback.current;
|
||||
successCallback.current = undefined;
|
||||
callback?.();
|
||||
},
|
||||
[persist],
|
||||
);
|
||||
|
||||
const openLogin = useCallback((onSuccess?: () => void) => {
|
||||
successCallback.current = onSuccess;
|
||||
@@ -76,7 +79,9 @@ export function AuthProvider({children}: {children: ReactNode}) {
|
||||
loginOpen,
|
||||
openLogin,
|
||||
closeLogin,
|
||||
sendOtp: async phone => { await requestOtp(phone); },
|
||||
sendOtp: async phone => {
|
||||
await requestOtp(phone);
|
||||
},
|
||||
verifyOtp: async (phone, code) => finishLogin(await loginWithOtp(phone, code)),
|
||||
loginPassword: async (phone, password) => finishLogin(await loginWithPassword(phone, password)),
|
||||
updateProfile: async profile => {
|
||||
@@ -90,7 +95,7 @@ export function AuthProvider({children}: {children: ReactNode}) {
|
||||
return (
|
||||
<AuthContext.Provider value={value}>
|
||||
{children}
|
||||
<AuthModal/>
|
||||
<AuthModal />
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export function LanguageProvider({children}: {children: ReactNode}) {
|
||||
window.localStorage.setItem('rm-locale', locale);
|
||||
}, [locale]);
|
||||
|
||||
const toggleLocale = () => setLocale((l) => (l === 'fa' ? 'en' : 'fa'));
|
||||
const toggleLocale = () => setLocale(l => (l === 'fa' ? 'en' : 'fa'));
|
||||
|
||||
return (
|
||||
<LanguageContext.Provider
|
||||
|
||||
@@ -14,11 +14,9 @@ interface ThemeContextValue {
|
||||
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
||||
|
||||
export function ThemeProvider({children}: {children: ReactNode}) {
|
||||
|
||||
const [theme, setTheme] = useState<Theme>('light');
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const saved = window.localStorage.getItem('rm-theme');
|
||||
if (saved === 'light' || saved === 'dark') {
|
||||
@@ -29,7 +27,6 @@ export function ThemeProvider({children}: {children: ReactNode}) {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement;
|
||||
root.classList.remove('light', 'dark');
|
||||
@@ -37,13 +34,9 @@ export function ThemeProvider({children}: {children: ReactNode}) {
|
||||
window.localStorage.setItem('rm-theme', theme);
|
||||
}, [theme]);
|
||||
|
||||
const toggleTheme = () => setTheme((t) => (t === 'dark' ? 'light' : 'dark'));
|
||||
const toggleTheme = () => setTheme(t => (t === 'dark' ? 'light' : 'dark'));
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{theme, setTheme, toggleTheme, mounted}}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
return <ThemeContext.Provider value={{theme, setTheme, toggleTheme, mounted}}>{children}</ThemeContext.Provider>;
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
|
||||
Reference in New Issue
Block a user