feat: implement user password reset functionality and enhance settings context

This commit is contained in:
2025-10-18 19:26:45 +02:00
parent 8ccca751aa
commit a6ac1e8140
13 changed files with 746 additions and 1337 deletions

View File

@@ -0,0 +1,45 @@
'use client';
import { createContext, useContext, useState, useEffect, ReactNode } from 'react';
interface Settings {
name: string;
logo: string;
}
interface SettingsContextType {
settings: Settings;
refetchSettings: () => void;
}
const SettingsContext = createContext<SettingsContextType | undefined>(undefined);
export function useSettings() {
const context = useContext(SettingsContext);
if (!context) {
throw new Error('useSettings must be used within a SettingsProvider');
}
return context;
}
export function SettingsProvider({ children }: { children: ReactNode }) {
const [settings, setSettings] = useState<Settings>({ name: '', logo: '' });
const fetchSettings = async () => {
const res = await fetch('/api/settings');
if (res.ok) {
const data = await res.json();
setSettings(data);
}
};
useEffect(() => {
fetchSettings();
}, []);
return (
<SettingsContext.Provider value={{ settings, refetchSettings: fetchSettings }}>
{children}
</SettingsContext.Provider>
);
}