diff --git a/app/admin/page.tsx b/app/admin/page.tsx index 236dd96..64a14c3 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -1,9 +1,66 @@ 'use client'; -import { useState, useEffect } from 'react'; -import { Card, Portal, MediaItem } from '@/types'; +import { useState, useEffect, useRef } from 'react'; +import { Card, Portal, MediaItem, CardType } from '@/types'; import { EXTERNAL_LINK_ENABLED } from '@/lib/config'; +function CardTypeSelect({ + value, + onChange, + options, +}: { + value: CardType; + onChange: (v: CardType) => void; + options: { value: CardType; label: string }[]; +}) { + const [open, setOpen] = useState(false); + const ref = useRef(null); + + useEffect(() => { + if (!open) return; + const onClick = (e: MouseEvent) => { + if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); + }; + const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') setOpen(false); }; + document.addEventListener('mousedown', onClick); + document.addEventListener('keydown', onKey); + return () => { + document.removeEventListener('mousedown', onClick); + document.removeEventListener('keydown', onKey); + }; + }, [open]); + + const current = options.find(o => o.value === value); + const inputBase = "w-full border border-gray-300 p-2.5 rounded-lg outline-none focus:ring-2 focus:ring-blue-500 bg-white text-gray-900"; + + return ( +
+ + {open && ( +
+ {options.map(o => ( + + ))} +
+ )} +
+ ); +} + const isVideoUrl = (url: string) => /\.(mp4|webm|mov|m4v|ogv)(\?|$)/i.test(url); const isPdfFile = (file: File) => file.type === 'application/pdf' || /\.pdf$/i.test(file.name); @@ -496,11 +553,15 @@ export default function AdminDashboard() {
- + setIsEditing({ ...isEditing, cardType: v })} + options={[ + { value: 'INFO_PAGE', label: 'Info Page' }, + { value: 'IMAGE_GALLERY', label: 'Image Gallery' }, + ...(EXTERNAL_LINK_ENABLED ? [{ value: 'EXTERNAL_LINK' as CardType, label: 'External Link' }] : []), + ]} + />
{isEditing.cardType === 'EXTERNAL_LINK' ? ( <>