'use client'; import { useEffect, useState } from 'react'; interface Service { id: string; name: string; description: string; is_active: boolean; order_index: number; } const SERVICE_ICONS: Record = { saju: '๐Ÿ”ฎ', lotto: '๐ŸŽฐ', stock: '๐Ÿ“ˆ', automation: '๐Ÿค–', prompt: '๐Ÿ’ก', freelance: '๐Ÿ› ', }; export default function AdminServicesPage() { const [services, setServices] = useState([]); const [loading, setLoading] = useState(true); const [toggling, setToggling] = useState(null); useEffect(() => { fetch('/api/admin/services') .then((r) => r.json()) .then((d) => setServices(d.services ?? [])) .catch(console.error) .finally(() => setLoading(false)); }, []); async function toggleService(id: string, current: boolean) { setToggling(id); try { const res = await fetch('/api/admin/services', { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, is_active: !current }), }); if (res.ok) { setServices((prev) => prev.map((s) => (s.id === id ? { ...s, is_active: !current } : s)) ); } } catch (e) { console.error(e); } finally { setToggling(null); } } return (

์„œ๋น„์Šค ์„ค์ •

๊ฐ ์„œ๋น„์Šค์˜ ๋…ธ์ถœ ์—ฌ๋ถ€๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค

{loading ? (
) : (
{services.map((service) => (
{SERVICE_ICONS[service.id] ?? '๐Ÿ“ฆ'}

{service.name}

{service.description}

{/* ํ† ๊ธ€ ์Šค์œ„์น˜ */}
{/* ์ƒํƒœ ๋ฐฐ์ง€ */}
{service.is_active ? 'ํ™œ์„ฑ' : '๋น„ํ™œ์„ฑ'} {!service.is_active && ( ์‚ฌ์ดํŠธ์—์„œ ์ˆจ๊ฒจ์ง‘๋‹ˆ๋‹ค )}
))}
)}

๐Ÿ’ก ์„œ๋น„์Šค on/off๋Š” Supabase์˜ service_settings ํ…Œ์ด๋ธ”์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. ์•„์ง ํ…Œ์ด๋ธ”์ด ์—†์œผ๋ฉด ์•„๋ž˜ SQL์„ ์‹คํ–‰ํ•˜์„ธ์š”.

{`CREATE TABLE service_settings (
  id text PRIMARY KEY,
  name text,
  description text,
  is_active boolean DEFAULT true,
  order_index integer DEFAULT 0,
  updated_at timestamptz DEFAULT now()
);`}
); }