'use client'; import { use } from 'react'; import { useRouter } from 'next/navigation'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { getApvreqDetail, requestApvreq, deleteApvreq, APRVL_STUS, APRVL_STUS_LABEL, APRVL_KIND_LABEL, } from '@/lib/api/tam'; import { useAuthStore } from '@/lib/store/authStore'; import ApvreqForm from '@/components/tam/ApvreqForm'; import ApproverSection from '@/components/tam/ApproverSection'; import ApvdocInfo from '@/components/tam/ApvdocInfo'; export default function Tam0020DetailPage({ params }: { params: Promise<{ docId: string }> }) { const { docId } = use(params); const router = useRouter(); const qc = useQueryClient(); const usrId = useAuthStore((s) => s.user?.usrId); const { data, isLoading } = useQuery({ queryKey: ['apvreq', docId], queryFn: () => getApvreqDetail(docId), }); const requestMut = useMutation({ mutationFn: (apprList: Array<{ apprId: string }>) => requestApvreq(docId, apprList), onSuccess: () => { qc.invalidateQueries({ queryKey: ['apvreq'] }); qc.invalidateQueries({ queryKey: ['apvreq', docId] }); alert('결재 상신이 완료되었습니다.'); }, onError: (e: any) => alert(e?.response?.data?.message ?? '상신 오류'), }); const delMut = useMutation({ mutationFn: () => deleteApvreq(docId), onSuccess: () => router.push('/tam/0020/list'), onError: (e: any) => alert(e?.response?.data?.message ?? '삭제 오류'), }); if (isLoading) return