RDII 분석 완료 상태 polling 및 전역 완료 alert 적용
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* - 로딩 오버레이 및 에러 핸들링 지원
|
||||
*
|
||||
* 🔗 사용 API
|
||||
* - 침입수분석 등록 첨부파일INP 포함: POST /api/v1/inftwtAnls/savewithfile (sewerage-service)
|
||||
* - RDII분석 등록 첨부파일INP 포함: POST /api/v1/rdiiAnls/savewithfile (sewerage-service)
|
||||
* - 로그인된 사용자의 사용자 정보 조회: GET /api/v1/users/info/me (user-service)
|
||||
*/
|
||||
"use client"
|
||||
@@ -22,6 +22,7 @@ import { postMutiPart } from '@/components/lib/api'
|
||||
import FileUploadForm from "@/components/ui/fileUploadForm"
|
||||
import FormSection from "@/components/ui/formSection"
|
||||
import BaseLayout from "../BaseLayout"
|
||||
import { useAnalysisCompletionWatcher } from "../useAnalysisCompletionWatcher"
|
||||
import { openAnalysisResultMapView } from "../analysisResultView"
|
||||
import { DateMonthPicker, filePicked } from "@common/business_components/ui"
|
||||
import { Input } from "@common/components/ui"
|
||||
@@ -142,6 +143,12 @@ export default function RTKForm() {
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
const { startWatching } = useAnalysisCompletionWatcher({
|
||||
buildStatusUrl: (analysisSn) => `v1/rdiiAnls/${analysisSn}/status`,
|
||||
successMessage: 'RDII 분석이 완료되었습니다.',
|
||||
failureMessage: 'RDII 분석이 실패했습니다. 로그를 확인해주세요.',
|
||||
});
|
||||
|
||||
// form 인스턴스 생성
|
||||
const form = useForm<FormSchemaType>({
|
||||
resolver: zodResolver(formSchema),
|
||||
@@ -183,16 +190,27 @@ export default function RTKForm() {
|
||||
};
|
||||
|
||||
const registFile = async (analysisData: any) => {
|
||||
setIsLoadingResult(true);
|
||||
const data = await postMutiPart('v1/rdiiAnls/savewithfile', analysisData);
|
||||
if (data) {
|
||||
setIsLoadingResult(false);
|
||||
alert("분석 데이터가 성공적으로 제출되었습니다.");
|
||||
resetAllForms(); // 성공 시 폼 초기화 함수 호출
|
||||
} else {
|
||||
setIsLoadingResult(false);
|
||||
alert("분석 데이터 제출 중 오류가 발생했습니다.");
|
||||
if (!data) {
|
||||
throw new Error('분석 요청 접수 응답이 비어 있습니다.');
|
||||
}
|
||||
|
||||
const nextAnalysisSn = Number(data?.rainInfwtAnlsSn ?? 0);
|
||||
const canWatchCompletion = Number.isFinite(nextAnalysisSn) && nextAnalysisSn > 0;
|
||||
|
||||
setIsLoadingResult(false);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
alert(
|
||||
canWatchCompletion
|
||||
? '분석 요청이 접수되었습니다. 완료 시 안내됩니다.'
|
||||
: '분석 요청이 접수되었습니다. 결과 목록에서 진행 상태를 확인해주세요.'
|
||||
);
|
||||
|
||||
if (canWatchCompletion) {
|
||||
startWatching(nextAnalysisSn);
|
||||
}
|
||||
|
||||
resetAllForms();
|
||||
};
|
||||
|
||||
// 침입수 분석 실행 버튼 클릭 핸들러
|
||||
@@ -381,8 +399,10 @@ export default function RTKForm() {
|
||||
setIsLoadingResult(false);
|
||||
} catch (error) {
|
||||
setIsLoadingResult(false);
|
||||
console.error("파일 파싱 중 오류 발생:", error);
|
||||
alert("파일 처리 중 오류가 발생했습니다.");
|
||||
console.error("RDII 분석 요청 처리 중 오류 발생:", error);
|
||||
alert(error instanceof Error && error.message.trim()
|
||||
? error.message
|
||||
: "파일 처리 중 오류가 발생했습니다.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { BaseLayout } from "@common/components";
|
||||
import type { MenuItem } from "@/entities/menu";
|
||||
import { useMenuStore } from "@/shared/lib";
|
||||
import { PageLayout } from "@/shared/ui/page-layout";
|
||||
import { GlobalAnalysisCompletionWatcher } from './ii/useAnalysisCompletionWatcher';
|
||||
import useStore from '../store/useStore';
|
||||
|
||||
export default function WithBaseLayout({
|
||||
@@ -48,12 +49,15 @@ export default function WithBaseLayout({
|
||||
};
|
||||
|
||||
return (
|
||||
<BaseLayout
|
||||
queryClient={queryClient}
|
||||
currentPath={pathname ?? ""}
|
||||
handleMenuClick={handleMenuClick}
|
||||
>
|
||||
<PageLayout>{children}</PageLayout>
|
||||
</BaseLayout>
|
||||
<>
|
||||
<GlobalAnalysisCompletionWatcher />
|
||||
<BaseLayout
|
||||
queryClient={queryClient}
|
||||
currentPath={pathname ?? ""}
|
||||
handleMenuClick={handleMenuClick}
|
||||
>
|
||||
<PageLayout>{children}</PageLayout>
|
||||
</BaseLayout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -56,3 +56,10 @@
|
||||
|
||||
- 사용자 요청에 따라 RDII 분석 화면 액션 버튼 순서를 `양식 받기 -> RDII분석 실행 -> 결과보기`로 조정했다.
|
||||
- 변경은 공통 `ii/BaseLayout.tsx` 렌더 순서만 수정해 침입수 분석 화면과 동일한 배치 규칙을 사용하도록 맞췄다.
|
||||
|
||||
## 11. 2026-07-09 RDII 분석 완료 alert 구현
|
||||
|
||||
- `ii/rdii/page.tsx`는 `savewithfile` 성공 직후 `분석 요청이 접수되었습니다. 완료 시 안내됩니다.` 문구를 먼저 보여주고, 응답의 `rainInfwtAnlsSn`으로 완료 감시를 시작하도록 바꿨다.
|
||||
- 감시는 공통 `ii/useAnalysisCompletionWatcher.ts`를 재사용해 `GET /api/v1/rdiiAnls/{rainInfwtAnlsSn}/status` polling과 `Y/N` 종료 alert를 처리한다.
|
||||
- `app/(with-base-layout)/layout.tsx`에 `GlobalAnalysisCompletionWatcher`를 mount해 사용자가 RDII 화면을 떠난 뒤에도 같은 레이아웃 범위 안에서는 완료 alert가 이어지도록 보강했다.
|
||||
- FE 정적 검증은 `node node_modules\typescript\bin\tsc --noEmit --ignoreDeprecations 5.0 -p tsconfig.json`까지 수행했고, 이번 RDII 완료 alert 변경 파일 기준 신규 오류는 없고 기존 선행 오류만 남았다.
|
||||
Reference in New Issue
Block a user