diff --git a/apps/sn/app/(with-base-layout)/ii/rdiiResult/page.tsx b/apps/sn/app/(with-base-layout)/ii/rdiiResult/page.tsx index 2af9cfc19..25fc6c374 100644 --- a/apps/sn/app/(with-base-layout)/ii/rdiiResult/page.tsx +++ b/apps/sn/app/(with-base-layout)/ii/rdiiResult/page.tsx @@ -92,6 +92,8 @@ const Result = () => { const handleSearchButtonClick = async (customFormValues?: Partial) => { setIsLoadingResult(true); + setResetSelection(true); + const formValues = customFormValues || form.getValues(); // react-hook-form에서 현재 값 가져오기 console.log("formValues", formValues); @@ -156,8 +158,10 @@ const Result = () => { }; }); - // setTableData(data.content || []); - // setTotalData(tableData.length); + // 선택된 행 초기화 + setSelectedRowData(null); + setSelectedRowIndex(undefined); + setTableData(dataWithRowNumber); setTotalData(dataWithRowNumber.length); console.log("response:", data); @@ -170,6 +174,7 @@ const Result = () => { setTableData([]); setTotalData(0); } + setResetSelection(false); }; // 테이블 셀 클릭 핸들러 추가 @@ -264,9 +269,6 @@ const Result = () => { }; await handleSearchButtonClick(customFormValues); - // 선택된 행 초기화 - setSelectedRowData(null); - setSelectedRowIndex(undefined); setIsLoadingResult(false); alert('삭제가 완료되었습니다.'); diff --git a/apps/sn/app/(with-base-layout)/ii/result/page.tsx b/apps/sn/app/(with-base-layout)/ii/result/page.tsx index ab8d397e0..e8dc11c11 100644 --- a/apps/sn/app/(with-base-layout)/ii/result/page.tsx +++ b/apps/sn/app/(with-base-layout)/ii/result/page.tsx @@ -83,12 +83,13 @@ const Result = () => { const [resetSelection, setResetSelection] = useState(false); useEffect(() => { - // setCurPage(1); - handleSearchButtonClick(); - }, []) + // setCurPage(1); + handleSearchButtonClick(); + }, []) const handleSearchButtonClick = async (customFormValues?: Partial) => { setIsLoadingResult(true); + setResetSelection(true); const formValues = customFormValues || form.getValues(); // react-hook-form에서 현재 값 가져오기 console.log("formValues", formValues); @@ -154,8 +155,11 @@ const Result = () => { scsYn: item.scsYn === null || item.scsYn === undefined ? 'N' : item.scsYn // scsYn이 null이면 'N'으로 변경 }; }); - // setTableData(data.content || []); - // setTotalData(tableData.length); + + // 선택된 행 초기화 + setSelectedRowData(null); + setSelectedRowIndex(undefined); + setTableData(dataWithRowNumber); setTotalData(dataWithRowNumber.length); console.log("response:", data); @@ -167,7 +171,10 @@ const Result = () => { alert("분석결과 조회 중 오류가 발생했습니다."); setTableData([]); setTotalData(0); + setSelectedRowData(null); + setSelectedRowIndex(undefined); } + setResetSelection(false); }; // 테이블 셀 클릭 핸들러 추가 @@ -265,16 +272,11 @@ const Result = () => { }; await handleSearchButtonClick(customFormValues); - // 선택된 행 초기화 - setSelectedRowData(null); - setSelectedRowIndex(undefined); setIsLoadingResult(false); alert('삭제가 완료되었습니다.'); - setTimeout(() => { - setResetSelection(false); - }, 100); + setResetSelection(false); } catch (error) { setIsLoadingResult(false); console.error("분석결과 파일 삭제 중 오류 발생:", error); @@ -282,7 +284,7 @@ const Result = () => { } }; - + return ( { const [totalData, setTotalData] = useState(0) //총 데이터 수 const [isLoading, setIsLoading] = useState(true) //로딩 상태 const [isModalOpen, setIsModalOpen] = useState(false) // 모달 상태 + const [resetSelection, setResetSelection] = useState(false); // 선택 초기화 상태 // 조회 const fetchData = async () => { setIsLoading(true) + setResetSelection(true); // searchCmmnCd('SITEKNDCD') try { const { data, total } = await searchData('v1/sbmrgPrevnt', { @@ -54,6 +56,7 @@ const Page = () => { setAtflId(''); setSbmrgPrevntBizSn(''); setIsLoading(false); + setResetSelection(false); } } @@ -85,6 +88,9 @@ const Page = () => { fetchData() } } + else { + alert('삭제에 실패했습니다.') + } } // 현황 등록 @@ -97,8 +103,8 @@ const Page = () => { atflId: id, sbmrgPrevntBizNm: fileName }) - if (data) { - alert('파일이 등록되었습니다.'); + if (data) { + alert('파일이 등록되었습니다.'); setIsModalOpen(false); fetchData(); } @@ -183,6 +189,7 @@ const Page = () => { } }} onPageChange={async (page: number) => { setCurPage(page); await fetchData() }} + resetSelection={resetSelection} /> {/* 파일 업로드 모달 */} diff --git a/apps/sn/app/(with-base-layout)/oper/oldPp/page.tsx b/apps/sn/app/(with-base-layout)/oper/oldPp/page.tsx index fb1725f55..af2e584f4 100644 --- a/apps/sn/app/(with-base-layout)/oper/oldPp/page.tsx +++ b/apps/sn/app/(with-base-layout)/oper/oldPp/page.tsx @@ -24,10 +24,12 @@ const Page = () => { const [totalData, setTotalData] = useState(0) //총 데이터 수 const [isLoading, setIsLoading] = useState(true) //로딩 상태 const [isModalOpen, setIsModalOpen] = useState(false) // 모달 상태 + const [resetSelection, setResetSelection] = useState(false); // 선택 초기화 상태 // 데이터 조회 const fetchData = async () => { setIsLoading(true) + setResetSelection(true); try { const { data, total } = await searchData('v1/dcrpPpl', { fromRegDt: formatDate(fromDate), @@ -51,6 +53,7 @@ const Page = () => { setAtflId(''); setDcrpPplMtncBizSn(''); setIsLoading(false) + setResetSelection(false); } } @@ -182,6 +185,7 @@ const Page = () => { } }} onPageChange={async (page: number) => { setCurPage(page); await fetchData() }} + resetSelection={resetSelection} /> {/* 파일 업로드 모달 */}