55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { postData } from "@/components/lib/api";
|
|
import OperFileUploadForm from "@/components/ui/operFileUploadForm";
|
|
import { tokenManager } from "@/entities/auth/lib/token-manager";
|
|
import { AUTH_USER_ID } from "@/shared/config";
|
|
import { useAlertStore } from "@/shared/lib";
|
|
import { StandardPopupLayout } from "@common/business_components";
|
|
import { postPopupMessageAndClose } from "../lib/popupMessage";
|
|
import { windowPopupDefinitions } from "../model/popupDefinitions";
|
|
import { WINDOW_POPUP_MESSAGE_TYPE } from "../model/types";
|
|
|
|
export default function OldPpUploadPopupContent() {
|
|
const alert = useAlertStore((state) => state.setMessage);
|
|
|
|
const handleSubmit = async (
|
|
fileNm: string,
|
|
year: string,
|
|
quater: string,
|
|
cd: string,
|
|
id: string,
|
|
) => {
|
|
// 공통 POST가 reject한 HTTP 오류를 팝업에서 처리해 완료 메시지를 보내지 않는다.
|
|
try {
|
|
const data = await postData("v1/dcrpPpl", {
|
|
mngYr: year,
|
|
mngQu: quater,
|
|
atflCd: cd,
|
|
atflId: id,
|
|
rgtr: tokenManager.getToken(AUTH_USER_ID) || null,
|
|
dcrpPplMtncBizNm: fileNm,
|
|
});
|
|
|
|
if (data) {
|
|
alert("파일이 등록되었습니다.", () =>
|
|
postPopupMessageAndClose(
|
|
WINDOW_POPUP_MESSAGE_TYPE.OLD_PP_UPLOAD_COMPLETED,
|
|
),
|
|
);
|
|
}
|
|
} catch {
|
|
alert("파일 등록에 실패했습니다. 잠시 후 다시 시도해주세요.");
|
|
}
|
|
};
|
|
|
|
return (
|
|
<StandardPopupLayout
|
|
title={windowPopupDefinitions.oldPpUpload.title}
|
|
bodyClassName="[&>div>div.card]:!m-0 [&>div>div:first-child]:hidden"
|
|
>
|
|
<OperFileUploadForm title="" onSubmit={handleSubmit} />
|
|
</StandardPopupLayout>
|
|
);
|
|
}
|