"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { useAuth } from "@/contexts/AuthContext"; import { solutionsApi, SolutionAdmin, getUploadUrl } from "@/lib/api"; import { Plus, Pencil, Trash2, Eye, EyeOff, Loader2, Image as ImageIcon, } from "lucide-react"; export default function SolutionsListPage() { const { token } = useAuth(); const [solutions, setSolutions] = useState([]); const [isLoading, setIsLoading] = useState(true); const fetchSolutions = async () => { if (!token) return; try { const data = await solutionsApi.adminGetAll(token); setSolutions(data); } catch (err) { console.error("Failed to fetch solutions:", err); } finally { setIsLoading(false); } }; useEffect(() => { fetchSolutions(); }, [token]); const handleDelete = async (id: number) => { if (!token || !confirm("정말 삭제하시겠습니까?")) return; try { await solutionsApi.adminDelete(id, token); setSolutions(solutions.filter((s) => s.id !== id)); } catch (err) { alert("삭제에 실패했습니다."); } }; const toggleActive = async (solution: SolutionAdmin) => { if (!token) return; try { await solutionsApi.adminUpdate( solution.id, { is_active: !solution.is_active }, token ); setSolutions( solutions.map((s) => s.id === solution.id ? { ...s, is_active: !s.is_active } : s ) ); } catch (err) { alert("상태 변경에 실패했습니다."); } }; if (isLoading) { return (
); } return (

솔루션 관리

새 솔루션
{solutions.length === 0 ? ( ) : ( solutions.map((solution) => ( )) )}
이미지 솔루션명 아이콘 색상 순서 상태 관리
등록된 솔루션이 없습니다.
{solution.main_image ? ( {solution.title_ko} ) : (
)}
{solution.title_ko}
{solution.title_en && (
{solution.title_en}
)}
{solution.icon || "-"} {solution.color || "-"} {solution.display_order}
); }