[ST] - feat: 통계 검증 리포트 상단 반려 기능 누락 부분 추가
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Label,
|
||||
Textarea,
|
||||
} from "@common/components";
|
||||
|
||||
export interface RejectReasonInputDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onConfirm?: (reason: string) => void | Promise<void>;
|
||||
}
|
||||
|
||||
export function RejectReasonInputDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
onConfirm,
|
||||
}: RejectReasonInputDialogProps) {
|
||||
const [reason, setReason] = useState("");
|
||||
const [reasonError, setReasonError] = useState(false);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const resetForm = () => {
|
||||
setReason("");
|
||||
setReasonError(false);
|
||||
};
|
||||
|
||||
const handleDialogOpenChange = (nextOpen: boolean) => {
|
||||
if (!nextOpen) resetForm();
|
||||
onOpenChange(nextOpen);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) resetForm();
|
||||
}, [open]);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
const trimmed = reason.trim();
|
||||
if (!trimmed) {
|
||||
setReasonError(true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setIsSubmitting(true);
|
||||
await onConfirm?.(trimmed);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const canSubmit = reason.trim().length > 0 && !isSubmitting;
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleDialogOpenChange}>
|
||||
<DialogContent
|
||||
className="max-w-[56rem]"
|
||||
aria-describedby={undefined}
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>반려</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-4 py-2">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label className="text-label mb-2">반려 사유</Label>
|
||||
<Textarea
|
||||
value={reason}
|
||||
onChange={(e) => {
|
||||
setReason(e.target.value);
|
||||
if (reasonError) setReasonError(false);
|
||||
}}
|
||||
className="min-h-[12rem] resize-y !text-[1.3rem] !leading-6"
|
||||
placeholder="반려 사유를 입력하세요."
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{reasonError && (
|
||||
<p className="text-[1.2rem] text-red-500">
|
||||
반려 사유를 작성해주세요.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button
|
||||
type="button"
|
||||
color="gray"
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
취소
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button
|
||||
type="button"
|
||||
color="red"
|
||||
disabled={!canSubmit}
|
||||
onClick={() => void handleConfirm()}
|
||||
>
|
||||
반려
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
type RejectRequest,
|
||||
type ReportStatusResponseDto,
|
||||
statisticsApprovalApi,
|
||||
type VrfcSttsRejectRequest,
|
||||
type StatisticsVerificationFilterState,
|
||||
statisticsVerificationReportColumnInfo,
|
||||
statisticsVerificationResultColumnInfo,
|
||||
@@ -52,6 +53,7 @@ import {
|
||||
type ApprovalFormData,
|
||||
ApprovalInputDialog,
|
||||
} from "@/components/statistics/verification/ApprovalInputDialog";
|
||||
import { RejectReasonInputDialog } from "@/components/statistics/verification/RejectReasonInputDialog";
|
||||
import type { CellEditedCallbackParams } from "@/components/type/DataGrid.type";
|
||||
import { doList } from "@/components/util/column/input/DoList";
|
||||
import { toGridRows } from "@/components/util/grid/gridFunction";
|
||||
@@ -181,6 +183,7 @@ function StatisticsVerificationReport() {
|
||||
VerifyResultItem[]
|
||||
>([]);
|
||||
const [approvalDialogOpen, setApprovalDialogOpen] = useState(false);
|
||||
const [rejectDialogOpen, setRejectDialogOpen] = useState(false);
|
||||
const editedResultRowMapRef = useRef<Map<number, VerifyResultItem>>(
|
||||
new Map(),
|
||||
);
|
||||
@@ -383,6 +386,11 @@ function StatisticsVerificationReport() {
|
||||
},
|
||||
});
|
||||
|
||||
const { mutateAsync: onVrfcSttsRejectStats } = useMutationWrapper({
|
||||
mutationFn: (rejectRequests: VrfcSttsRejectRequest[]) =>
|
||||
statisticsApprovalApi.VrfcSttsRejectStats(rejectRequests),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!statisticsVerificationReportQuery.isError) return;
|
||||
alert("통계검증리포트 조회 중 오류가 발생했습니다.");
|
||||
@@ -593,6 +601,58 @@ function StatisticsVerificationReport() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleVrfcSttsReject() {
|
||||
if (selectedReportRows.length === 0) return;
|
||||
setRejectDialogOpen(true);
|
||||
}
|
||||
|
||||
async function handleVrfcSttsRejectConfirm(reason: string) {
|
||||
const rjctOpnnCn = reason.trim();
|
||||
if (!rjctOpnnCn) {
|
||||
alert("반려 사유를 작성해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
const rejectRequests: VrfcSttsRejectRequest[] = selectedReportRows.map(
|
||||
(row) => ({
|
||||
statsYr: filters.statsYr,
|
||||
sewerBzmnCd: row.sewerBzmnCd ?? "",
|
||||
statsCd: row.statsCd ?? "",
|
||||
rjctOpnnCn,
|
||||
mdfrUuid: userInfo?.userUnqId ?? "",
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const data = await onVrfcSttsRejectStats(rejectRequests);
|
||||
if (
|
||||
data.resultCode &&
|
||||
data.resultCode.toLowerCase() !== "success"
|
||||
) {
|
||||
alert(data.message || "반려 중 오류가 발생했습니다.");
|
||||
return;
|
||||
}
|
||||
alert(data.message ?? "반려가 완료되었습니다.");
|
||||
setRejectDialogOpen(false);
|
||||
setSelectedReportRows([]);
|
||||
resetResultState();
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.ST_SERVICE.INPUT, "validation-report"],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [
|
||||
ENDPOINT.ST_SERVICE.INPUTVERIFY,
|
||||
"verify-results",
|
||||
],
|
||||
}),
|
||||
]);
|
||||
} catch {
|
||||
alert("반려 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleReportRefresh() {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [ENDPOINT.ST_SERVICE.INPUT, "validation-report"],
|
||||
@@ -612,6 +672,11 @@ function StatisticsVerificationReport() {
|
||||
onOpenChange={setApprovalDialogOpen}
|
||||
onConfirm={handleApprovalConfirm}
|
||||
/>
|
||||
<RejectReasonInputDialog
|
||||
open={rejectDialogOpen}
|
||||
onOpenChange={setRejectDialogOpen}
|
||||
onConfirm={handleVrfcSttsRejectConfirm}
|
||||
/>
|
||||
<div className="flex justify-between p-2">
|
||||
<div className="flex items-center gap-6">
|
||||
<FilterSelect
|
||||
@@ -679,6 +744,18 @@ function StatisticsVerificationReport() {
|
||||
>
|
||||
승인
|
||||
</Button>
|
||||
<Button
|
||||
color="red"
|
||||
onClick={handleVrfcSttsReject}
|
||||
disabled={selectedReportRows.length === 0 ||
|
||||
!selectedReportRows.every(
|
||||
(row) =>
|
||||
row.mctpvPicSbmsnSttsCd === "3" && row.pbcpSbmsnSttsCd !== "3",
|
||||
)
|
||||
}
|
||||
>
|
||||
반려
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import type {
|
||||
ApproveRequest,
|
||||
RejectRequest,
|
||||
StatisticsApprovalService,
|
||||
VrfcSttsRejectRequest,
|
||||
VrfcSttsRejectResponse,
|
||||
} from "../model/statistics-approval-interface";
|
||||
|
||||
class StatisticsApprovalApiService implements StatisticsApprovalService {
|
||||
@@ -28,6 +30,14 @@ class StatisticsApprovalApiService implements StatisticsApprovalService {
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async VrfcSttsRejectStats(params: VrfcSttsRejectRequest[]): Promise<VrfcSttsRejectResponse> {
|
||||
const response = await client.post<VrfcSttsRejectResponse>(
|
||||
`${ENDPOINT.ST_SERVICE.APPROVAL}/reject?type=VRFC_STTS`,
|
||||
params,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const statisticsApprovalApi = new StatisticsApprovalApiService();
|
||||
|
||||
@@ -146,6 +146,7 @@ export {
|
||||
type ApprovalResponse,
|
||||
type ApproveRequest,
|
||||
type RejectRequest,
|
||||
type VrfcSttsRejectRequest,
|
||||
} from "./model/statistics-approval-interface";
|
||||
export {
|
||||
type SearchCondition,
|
||||
|
||||
@@ -25,7 +25,23 @@ export interface ApprovalResponse {
|
||||
exceptionCnt: number;
|
||||
}
|
||||
|
||||
|
||||
export interface VrfcSttsRejectRequest {
|
||||
statsYr: string;
|
||||
sewerBzmnCd: string;
|
||||
statsCd: string;
|
||||
rjctOpnnCn: string;
|
||||
mdfrUuid: string;
|
||||
}
|
||||
|
||||
export interface VrfcSttsRejectResponse {
|
||||
message: string;
|
||||
resultCode: string;
|
||||
updatedStts: string;
|
||||
}
|
||||
|
||||
export interface StatisticsApprovalService {
|
||||
approveStats(params: ApproveRequest[]): Promise<ApprovalResponse>;
|
||||
rejectStats(params: RejectRequest[]): Promise<ApprovalResponse>;
|
||||
VrfcSttsRejectStats(params: VrfcSttsRejectRequest[]): Promise<VrfcSttsRejectResponse>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user