"use client"; import { useState } from "react"; import { useTranslations } from "next-intl"; import { useAuthStore } from "@/lib/stores/auth.store"; import { PageHeader } from "@/components/layout/page-header"; import { SettingsNav } from "@/components/settings/settings-nav"; import { SettingsAppearancePanel } from "@/components/settings/settings-appearance-panel"; import { CafeDiscoverProfilePanel } from "@/components/discover/cafe-discover-profile-panel"; import { CafePublicProfilePanel } from "@/components/discover/cafe-public-profile-panel"; import { SettingsShopPanel } from "@/components/settings/settings-shop-panel"; import { SettingsTerminalsPanel } from "@/components/settings/settings-terminals-panel"; import { SettingsPrinterPanel } from "@/components/settings/settings-printer-panel"; import { SettingsPrintTestPanel } from "@/components/settings/settings-print-test-panel"; import { DEFAULT_SETTINGS_LEAF, groupForLeaf, type SettingsGroupId, type SettingsLeafId, } from "@/components/settings/settings-types"; const LEAF_PAGE_TITLE: Record = { "shop-general": "nav.shopGeneral", "shop-appearance": "nav.shopAppearance", "shop-discover": "nav.shopDiscover", "printer-config": "nav.printerSettings", "print-test": "nav.printTest", }; export function SettingsScreen() { const t = useTranslations("settings"); const cafeId = useAuthStore((s) => s.user?.cafeId); const [activeLeaf, setActiveLeaf] = useState(DEFAULT_SETTINGS_LEAF); const [expandedGroup, setExpandedGroup] = useState("shop"); const selectLeaf = (leaf: SettingsLeafId) => { setActiveLeaf(leaf); setExpandedGroup(groupForLeaf(leaf)); }; const toggleGroup = (group: SettingsGroupId) => { setExpandedGroup((prev) => (prev === group ? prev : group)); const firstChild = group === "shop" ? "shop-general" : "printer-config"; if (groupForLeaf(activeLeaf) !== group) { selectLeaf(firstChild); } }; if (!cafeId) return null; const pageTitle = t(LEAF_PAGE_TITLE[activeLeaf]); return (

{pageTitle}

{activeLeaf === "shop-general" ? (
) : null} {activeLeaf === "shop-appearance" ? ( ) : null} {activeLeaf === "shop-discover" ? (
) : null} {activeLeaf === "printer-config" ? ( selectLeaf("print-test")} /> ) : null} {activeLeaf === "print-test" ? ( selectLeaf("printer-config")} /> ) : null}
); }