"use client"; import { useState, useEffect, useMemo } from 'react'; import { CodeSelectWithAll } from '@/entities/code'; import { Button, Label, Select, SelectTrigger, SelectContent, SelectValue, SelectItem, DataTable, } from "@common/components"; import { LoadingWithAnimation } from '@common/components'; import { NoData } from '@/shared/ui/no-data'; import DetailComponent from './generalVerification/DetailComponent'; import RegistDialog from './generalVerification/RegistDialog'; import { getCoreRowModel, useReactTable } from "@tanstack/react-table"; import { getGeneralVerificationColumns } from '@/components/util/column/management/GeneralVerificationColumn'; import type { GeneralverificationList } from '@/entities/statistics/model/general-verification-interface'; import { generalverificationApiService } from '@/entities/statistics/api/general-verification-service'; import { useAlertStore } from '@/shared/lib'; const GeneralVerificationManagement = () => { const [searchValues, setSearchValues] = useState<{ statsCd: string; useYn: string; vrfcClsfCd: string; }>({ statsCd: '', useYn: '', vrfcClsfCd: '', }); const [vrfcMasterData, setVrfcMasterData] = useState([]); const [rowSelection, setRowSelection] = useState>({}); const [isLoading, setIsLoading] = useState(false); const [selectedVrfcRow, setSelectedVrfcRow] = useState(null); const [showRegistForm, setShowRegistForm] = useState(false); const { setMessage: alert } = useAlertStore((state) => state); const handleSearch = async () => { try { setIsLoading(true); const params = Object.fromEntries( Object.entries({ trgtStatsCd: searchValues.statsCd, vrfcClsfCd: searchValues.vrfcClsfCd, useYn: searchValues.useYn, }).filter(([, value]) => value !== '' && value !== 'ALL') ); const response = await generalverificationApiService.getGeneralverificationList(params); if (response.status === 'success') { setVrfcMasterData(response.data); setRowSelection({}); setSelectedVrfcRow(null); setShowRegistForm(false); } else { alert(response.message || '데이터 조회 중 오류가 발생했습니다.'); } } catch { alert('데이터 조회 중 오류가 발생했습니다.'); } finally { setIsLoading(false); } }; const columns = useMemo( () => getGeneralVerificationColumns(handleSearch), [searchValues.statsCd, searchValues.vrfcClsfCd, searchValues.useYn], ); const table = useReactTable({ data: vrfcMasterData, columns, getCoreRowModel: getCoreRowModel(), getRowId: (row) => String(row.vrfcSn), state: { rowSelection }, onRowSelectionChange: setRowSelection, }); const handleVrfcMasterRowClick = async (row: GeneralverificationList) => { setRowSelection({ [row.vrfcSn]: true }); setSelectedVrfcRow(row.vrfcSn); setShowRegistForm(false); }; const handleReset = () => { setRowSelection({}); setSelectedVrfcRow(null); handleSearch(); setShowRegistForm(false); } useEffect(() => { handleSearch(); }, []); return (
setSearchValues({ ...searchValues, statsCd: value })} placeholder="전체" className="w-[16rem]" />

일반 검증 목록

{isLoading && (
)} {isLoading ? null : vrfcMasterData.length > 0 ? handleVrfcMasterRowClick(value)} /> :
}
); }; export default GeneralVerificationManagement;