From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 28 Apr 2025 02:13:30 +0000 Subject: ~20250428 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/project-series-dialog.tsx | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 lib/bidding-projects/table/project-series-dialog.tsx (limited to 'lib/bidding-projects/table/project-series-dialog.tsx') diff --git a/lib/bidding-projects/table/project-series-dialog.tsx b/lib/bidding-projects/table/project-series-dialog.tsx new file mode 100644 index 00000000..168ede7e --- /dev/null +++ b/lib/bidding-projects/table/project-series-dialog.tsx @@ -0,0 +1,133 @@ +"use client" + +import * as React from "react" +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog" +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" +import { BiddingProjects } from "@/db/schema" +import { useToast } from "@/hooks/use-toast" + +// Import the function +import { getProjectSeriesForProject } from "../service" + +// Define the ProjectSeries type based on the schema +interface ProjectSeries { + pspid: string; + sersNo: string; + scDt?: string | null; + klDt?: string | null; + lcDt?: string | null; + dlDt?: string | null; + dockNo?: string | null; + dockNm?: string | null; + projNo?: string | null; + post1?: string | null; +} + +interface ProjectSeriesDialogProps { + open: boolean + onOpenChange: (open: boolean) => void + project: BiddingProjects | null +} + +export function ProjectSeriesDialog({ + open, + onOpenChange, + project, +}: ProjectSeriesDialogProps) { + const { toast } = useToast() + + const [projectSeries, setProjectSeries] = React.useState([]) + const [isLoading, setIsLoading] = React.useState(false) + + React.useEffect(() => { + async function loadItems() { + if (!project?.pspid) return; + + setIsLoading(true) + try { + const result = await getProjectSeriesForProject(project.pspid) + setProjectSeries(result) + } catch (error) { + console.error("프로젝트 시리즈 로드 오류:", error) + toast({ + title: "오류", + description: "프로젝트 시리즈 로드 실패", + variant: "destructive", + }) + } finally { + setIsLoading(false) + } + } + + if (open && project) { + loadItems() + } + }, [toast, project, open]) + + return ( + + + + + {project ? `시리즈 목록 - ${project.projNm || project.pspid}` : "시리즈 목록"} + + + {isLoading ? ( +
+ 로딩 중... +
+ ) : ( +
+ + + + 시리즈번호 + K/L 연도분기 + 도크코드 + 도크명 + SN공사번호 + SN공사명 + + + + {projectSeries && projectSeries.length > 0 ? ( + projectSeries.map((series) => ( + + {series.sersNo} + {series.scDt} + {series.klDt} + {series.lcDt} + {series.dlDt} + {series.dockNo} + {series.dockNm} + {series.projNo} + {series.post1} + + )) + ) : ( + + + 시리즈 데이터가 없습니다. + + + )} + +
+
+ )} +
+
+ ) +} \ No newline at end of file -- cgit v1.2.3