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"; import type { Currency, WeightUnit } from "../lib/formatters"; const UNITS: WeightUnit[] = ["g", "oz", "lb", "kg"]; const CURRENCIES: { value: Currency; label: string }[] = [ { value: "USD", label: "$" }, { value: "EUR", label: "€" }, { value: "GBP", label: "£" }, { value: "JPY", label: "¥" }, { value: "CAD", label: "CA$" }, { value: "AUD", label: "A$" }, ]; 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] = useStateAPI 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}
Choose the unit used to display weights across the app
Changes the currency symbol displayed. This does not convert values.