diff --git a/src/client/routes/settings.tsx b/src/client/routes/settings.tsx index 0aab7cf..d3e9014 100644 --- a/src/client/routes/settings.tsx +++ b/src/client/routes/settings.tsx @@ -1,4 +1,12 @@ import { createFileRoute, Link } from "@tanstack/react-router"; +import { useState } from "react"; +import { + useApiKeys, + useAuth, + useChangePassword, + useCreateApiKey, + useDeleteApiKey, +} from "../hooks/useAuth"; import { useCurrency } from "../hooks/useCurrency"; import { useUpdateSetting } from "../hooks/useSettings"; import { useWeightUnit } from "../hooks/useWeightUnit"; @@ -18,10 +26,157 @@ export const Route = createFileRoute("/settings")({ component: SettingsPage, }); +function ChangePasswordSection() { + const changePassword = useChangePassword(); + const [currentPassword, setCurrentPassword] = useState(""); + const [newPassword, setNewPassword] = useState(""); + const [message, setMessage] = useState<{ + type: "success" | "error"; + text: string; + } | null>(null); + + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + setMessage(null); + try { + await changePassword.mutateAsync({ currentPassword, newPassword }); + setMessage({ type: "success", text: "Password changed" }); + setCurrentPassword(""); + setNewPassword(""); + } catch (err) { + setMessage({ type: "error", text: (err as Error).message }); + } + } + + return ( +
+ ); +} + +function ApiKeySection() { + const { data: keys } = useApiKeys(); + const createKey = useCreateApiKey(); + const deleteKey = useDeleteApiKey(); + const [name, setName] = useState(""); + const [newKey, setNewKey] = useState+ API keys allow programmatic access to GearBox (e.g., from Claude Desktop + or scripts). +
+ + {newKey && ( ++ Copy this key now — it won't be shown again: +
+
+ {newKey}
+
+
+