"use client"; import { Drawing } from "@/types/drawing"; import { DrawingCard } from "@/components/drawings/card"; import { drawingApi } from "@/lib/api/drawings"; import { useEffect, useState } from "react"; import { Loader2 } from "lucide-react"; interface DrawingListProps { type: "CONTRACT" | "SHOP"; } export function DrawingList({ type }: DrawingListProps) { const [drawings, setDrawings] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const fetchDrawings = async () => { setLoading(true); try { const data = await drawingApi.getAll({ type }); setDrawings(data); } catch (error) { console.error("Failed to fetch drawings", error); } finally { setLoading(false); } }; fetchDrawings(); }, [type]); if (loading) { return (
); } if (drawings.length === 0) { return (
No drawings found.
); } return (
{drawings.map((drawing) => ( ))}
); }