"use client"; import { DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, } from "@suphark/ui/components/ui/dropdown-menu"; import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react"; import { useTheme } from "next-themes"; import type { ReactNode } from "react"; import { useUiText } from "../ui-text"; import type { Theme } from "./theme-provider"; const ICONS: Record = { light: , dark: , system: , }; const ORDER: Theme[] = ["light", "dark", "system"]; /** * กลุ่มตัวเลือกธีมสำหรับใส่ใน DropdownMenu (เช่นเมนูผู้ใช้) — ยกจาก Pi Auth มาบน next-themes * ข้อความค่าเริ่มต้นจาก `UiText.theme`; `onThemeChange` ให้แอปบันทึกธีมเป็น preference ของบัญชี (ซิงก์ข้ามเครื่อง) */ export function ThemeMenuItems({ label, labels, onThemeChange, }: { label?: ReactNode; /** ข้อความแต่ละตัวเลือก (ค่าเริ่มต้นจาก UiText.theme / ไทย) */ labels?: Partial>; /** เรียกหลัง setTheme — เช่น server action บันทึก preference */ onThemeChange?: (theme: Theme) => void | Promise; }) { const { theme = "system", setTheme } = useTheme(); const text = useUiText().theme; return ( {label ?? text?.label ?? "ธีม"} { setTheme(v as Theme); void onThemeChange?.(v as Theme); }} > {ORDER.map((value) => ( {ICONS[value]} {labels?.[value] ?? text?.[value] ?? value} ))} ); }