"use client"; // 개발관리 > PART 상세 조회 다이얼로그 (read-only). // 행 더블클릭 진입. "수정" 버튼 클릭 시 PartFormDialog(mode='edit')로 전환은 // 호출 페이지가 dispatch (open=false → 부모가 form dialog 오픈). import React, { useEffect, useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Loader2, Pencil } from "lucide-react"; import { toast } from "sonner"; import { devPartApi, PartRow } from "@/lib/api/devPart"; interface Props { open: boolean; onOpenChange: (open: boolean) => void; objid: string | null; /** "수정" 버튼 클릭 시 호출 — 부모는 본 다이얼로그 닫고 PartFormDialog(mode='edit')를 띄움 */ onEdit?: (objid: string) => void; } export function PartDetailDialog({ open, onOpenChange, objid, onEdit }: Props) { const [row, setRow] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { if (!open || !objid) return; let alive = true; setLoading(true); devPartApi.detail(objid) .then((data) => { if (alive) setRow(data); }) .catch((e: any) => { toast.error(e?.response?.data?.message ?? e?.message ?? "조회 실패"); onOpenChange(false); }) .finally(() => { if (alive) setLoading(false); }); return () => { alive = false; }; }, [open, objid, onOpenChange]); if (!open) return null; return ( PART 상세 정보 {loading || !row ? (
) : (
)} {row && onEdit && ( )}
); } // ─── 보조 ───────────────────────────────────────────────── function Section({ title, children }: { title: string; children: React.ReactNode }) { return (
{title}
{children}
); } function Row({ children }: { children: React.ReactNode }) { return
{children}
; } function V({ label, value, align }: { label: string; value: any; align?: "left" | "center" | "right" }) { const cls = align === "right" ? "text-right" : align === "center" ? "text-center" : ""; return (
{label && }
{value != null && value !== "" ? value : }
); }