"use client"; import { useState } from "react"; import { useParams } from "next/navigation"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { AppLayout } from "@/components/layout/AppLayout"; import api from "@/lib/api"; import type { InspectionRequest } from "@/lib/types"; import { formatDate } from "@/lib/utils"; import Link from "next/link"; const INSPECTION_TYPES = [ "철근 검측", "거푸집 검측", "콘크리트 타설 전 검측", "관로 매설 검측", "성토 다짐 검측", "도로 포장 검측", "기타", ]; export default function InspectionsPage() { const { id } = useParams<{ id: string }>(); const qc = useQueryClient(); const [showForm, setShowForm] = useState(false); const [generating, setGenerating] = useState(false); const { data: inspections = [], isLoading } = useQuery({ queryKey: ["inspections", id], queryFn: () => api.get(`/projects/${id}/inspections`).then((r) => r.data), }); async function handleGenerate(data: Record) { setGenerating(true); try { await api.post(`/projects/${id}/inspections/generate`, data); qc.invalidateQueries({ queryKey: ["inspections", id] }); setShowForm(false); } finally { setGenerating(false); } } const resultLabels: Record = { pass: { label: "합격", cls: "badge-green" }, fail: { label: "불합격", cls: "badge-red" }, conditional_pass: { label: "조건부 합격", cls: "badge-yellow" }, }; const statusLabels: Record = { draft: "초안", sent: "발송완료", completed: "검측완료", }; return (
← 현장

검측요청서

{showForm && (

검측요청서 AI 생성

{ e.preventDefault(); const fd = new FormData(e.target as HTMLFormElement); handleGenerate({ inspection_type: fd.get("inspection_type"), requested_date: fd.get("requested_date"), location_detail: fd.get("location_detail") || undefined, }); }} className="grid grid-cols-2 gap-4" >
)}
{isLoading ? ( ) : inspections.length === 0 ? ( ) : ( inspections.map((insp) => ( )) )}
요청일 공종 위치 체크리스트 결과 상태 생성방식
로딩 중...
검측요청서가 없습니다
{formatDate(insp.requested_date)} {insp.inspection_type} {insp.location_detail || "-"} {insp.checklist_items ? `${insp.checklist_items.length}개 항목` : "-"} {insp.result ? ( {resultLabels[insp.result]?.label} ) : "-"} {statusLabels[insp.status]} {insp.ai_generated ? AI : 수동}
); }