diff --git a/app/dashboard/scenes/page.tsx b/app/dashboard/scenes/page.tsx index dc7fcd9..9f88a24 100644 --- a/app/dashboard/scenes/page.tsx +++ b/app/dashboard/scenes/page.tsx @@ -13,6 +13,7 @@ import { Input, Modal, PageHeader, + Select, Switch, } from "@/components/ui"; import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons"; @@ -20,21 +21,59 @@ import { toFa } from "@/lib/utils"; import { MediaPreview } from "@/components/MediaPreview"; import { pickUrl, SOUND_KEYS, VIDEO_KEYS, IMAGE_KEYS } from "@/lib/media"; +interface Theme { + id: number; + key: string; + name: string; + colors: Record; +} + interface Scene { id: number; name: string; order?: number; is_active?: boolean; + theme_id?: number | null; + theme?: Theme | null; +} + +// "#FF156395" (ARGB) or "#156395" → a CSS color the browser understands. +function cssColor(c?: string): string { + if (!c) return "transparent"; + const hex = c.replace("#", ""); + if (hex.length === 8) return `#${hex.slice(2)}${hex.slice(0, 2)}`; // ARGB → RGBA + return `#${hex}`; +} + +function ThemeSwatch({ theme }: { theme?: Theme | null }) { + if (!theme) return ; + const keys = ["themeUp", "themeDown", "lightColorGradient", "darkColorGradient"]; + return ( + + + {keys.map((k) => ( + + ))} + + {theme.name} + + ); } export default function ScenesPage() { const { data, loading, error, reload } = useList("/scenes"); + const { data: themes } = useList("/themes"); const toast = useToast(); const [editing, setEditing] = useState(null); const [open, setOpen] = useState(false); const [name, setName] = useState(""); const [order, setOrder] = useState(""); + const [themeId, setThemeId] = useState(""); const [isActive, setIsActive] = useState(true); const [image, setImage] = useState(null); const [video, setVideo] = useState(null); @@ -48,6 +87,7 @@ export default function ScenesPage() { setEditing(null); setName(""); setOrder(""); + setThemeId(""); setIsActive(true); setImage(null); setVideo(null); @@ -58,6 +98,7 @@ export default function ScenesPage() { setEditing(row); setName(row.name ?? ""); setOrder(row.order != null ? String(row.order) : ""); + setThemeId(row.theme_id != null ? String(row.theme_id) : ""); setIsActive(!!row.is_active); setImage(null); setVideo(null); @@ -73,6 +114,7 @@ export default function ScenesPage() { const body = toFormData({ name, order, + theme_id: themeId, is_active: isActive, image, video, @@ -112,6 +154,11 @@ export default function ScenesPage() { const columns: Column[] = [ { key: "id", header: "شناسه", render: (r) => toFa(r.id), className: "w-24" }, { key: "name", header: "نام صحنه" }, + { + key: "theme", + header: "قالب رنگی", + render: (r) => , + }, { key: "image", header: "تصویر", @@ -236,6 +283,24 @@ export default function ScenesPage() { /> + + + {themeId && ( +
+ String(t.id) === themeId) ?? null} + /> +
+ )} +
+