[st] feat: 검증 이력 테이블 수정
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
DataTable,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
@@ -27,14 +29,17 @@ import {
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from "@common/components";
|
||||
import { verificationHistoryColumnInfo } from "@/entities/statistics/model/verification-history-column";
|
||||
import { verificationHistoryColumns } from "@/entities/statistics/model/verification-history-columns";
|
||||
import { analysisApi } from "@/entities/statistics/api/analysis-api";
|
||||
import { analysisHistoryApi } from "@/entities/statistics/api/analysis-history-api";
|
||||
import type {
|
||||
AnalysisRequestPayload,
|
||||
AnalysisResponseDto,
|
||||
} from "@/entities/statistics/model/analysis-interface";
|
||||
import type { StAnlsOutlierListResponse } from "@/entities/statistics/model/analysis-history-interface";
|
||||
import type {
|
||||
StAnlsMstResponse,
|
||||
StAnlsOutlierListResponse,
|
||||
} from "@/entities/statistics/model/analysis-history-interface";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { CodeApi } from "@/entities/code";
|
||||
@@ -70,6 +75,7 @@ function toNumber(value: string): number {
|
||||
}
|
||||
|
||||
const HbStatisticsVerification = () => {
|
||||
const router = useRouter();
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -103,20 +109,34 @@ const HbStatisticsVerification = () => {
|
||||
|
||||
const { data: analysisHistory } = useQuery({
|
||||
queryKey: [ENDPOINT.STATVERIFY_SERVICE.ST_ANLS_MST],
|
||||
queryFn: async () => {
|
||||
const response = await analysisHistoryApi.getAnalysisHistoryList({
|
||||
queryFn: () =>
|
||||
analysisHistoryApi.getAnalysisHistoryList({
|
||||
page: 0,
|
||||
size: 10,
|
||||
});
|
||||
return response;
|
||||
}),
|
||||
refetchInterval: (query) => {
|
||||
const data = query.state.data;
|
||||
if (!data?.content?.length) return false;
|
||||
const hasProcessing = (data.content as StAnlsMstResponse[]).some(
|
||||
(item) => item.anlsSttsCd === "PROCESSING",
|
||||
);
|
||||
return hasProcessing ? 3000 : false;
|
||||
},
|
||||
});
|
||||
|
||||
const historyRowData =
|
||||
(analysisHistory?.content ?? []) as unknown as Record<
|
||||
string,
|
||||
string | number
|
||||
>[];
|
||||
const historyRowData: StAnlsMstResponse[] = (analysisHistory?.content ??
|
||||
[]) as StAnlsMstResponse[];
|
||||
|
||||
const table = useReactTable({
|
||||
data: historyRowData,
|
||||
columns: verificationHistoryColumns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
meta: {
|
||||
onOutlierCellClick: (row: StAnlsMstResponse) => {
|
||||
setOutlierDialog({ open: true, anlsSn: row.anlsSn });
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const { data: outlierList, isLoading: isLoadingOutlier } = useQuery({
|
||||
queryKey: [
|
||||
@@ -212,11 +232,10 @@ const HbStatisticsVerification = () => {
|
||||
setSelectedTargets([]);
|
||||
}
|
||||
|
||||
function handleHistoryRowClick(row: Record<string, string | number>) {
|
||||
const abnormalCount = Number(row.otlrDataNocs ?? 0);
|
||||
function handleHistoryRowClick(row: StAnlsMstResponse) {
|
||||
const anlsSn = Number(row.anlsSn ?? 0);
|
||||
if (!anlsSn || abnormalCount <= 0) return;
|
||||
setOutlierDialog({ open: true, anlsSn });
|
||||
if (!anlsSn) return;
|
||||
router.push(`/statistics/verification/${anlsSn}`);
|
||||
}
|
||||
|
||||
function closeOutlierDialog() {
|
||||
@@ -417,25 +436,16 @@ const HbStatisticsVerification = () => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-10 px-2">
|
||||
<div className="mt-10 px-4 pb-8">
|
||||
<h3 className="mb-2 px-2 text-[1.5rem] font-semibold text-title">
|
||||
검증 이력
|
||||
</h3>
|
||||
<DataGrid
|
||||
columnInfo={verificationHistoryColumnInfo}
|
||||
rowData={historyRowData}
|
||||
setRowData={() => {}}
|
||||
isExcelImport={false}
|
||||
isExcelExport={false}
|
||||
showHeaderCheckbox={false}
|
||||
<DataTable
|
||||
table={table}
|
||||
variant="secondary"
|
||||
onRowClick={handleHistoryRowClick}
|
||||
cellStyleCallback={({ row, fieldName }) => {
|
||||
if (fieldName === "otlrDataNocs") {
|
||||
const abnormal = Number(row.otlrDataNocs ?? 0);
|
||||
if (abnormal > 0) return "rg-cell-verify-error";
|
||||
}
|
||||
return "";
|
||||
}}
|
||||
viewPagination={true}
|
||||
className="[&_td]:!p-0"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user