fix: propagate settings save into live App.tsx state instead of requiring re-login
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V57jSQPqwkGG8BuAXg59X5
This commit is contained in:
parent
aec27bc136
commit
effa9168c1
|
|
@ -57,7 +57,14 @@ export default function App() {
|
|||
</nav>
|
||||
{view === "chat" && <Chat assistantName={assistantName} />}
|
||||
{view === "dashboard" && <Dashboard />}
|
||||
{view === "settings" && <Settings />}
|
||||
{view === "settings" && (
|
||||
<Settings
|
||||
onSaved={(settings) => {
|
||||
setAssistantName(settings.assistant_name);
|
||||
document.title = settings.assistant_name;
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import { apiFetch } from "../api";
|
|||
|
||||
type SettingsData = { assistant_name: string; company_name: string; contact_email: string };
|
||||
|
||||
export default function Settings() {
|
||||
type SettingsProps = { onSaved?: (settings: SettingsData) => void };
|
||||
|
||||
export default function Settings({ onSaved }: SettingsProps) {
|
||||
const [settings, setSettings] = useState<SettingsData | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
|
@ -45,7 +47,9 @@ export default function Settings() {
|
|||
setError("Speichern fehlgeschlagen");
|
||||
return;
|
||||
}
|
||||
setSettings(await response.json());
|
||||
const updated = await response.json();
|
||||
setSettings(updated);
|
||||
onSaved?.(updated);
|
||||
setSaved(true);
|
||||
} catch {
|
||||
setError("Speichern fehlgeschlagen");
|
||||
|
|
|
|||
Loading…
Reference in New Issue