From 47ff577c336b34271165b96f8796b1fb36615941 Mon Sep 17 00:00:00 2001 From: jnkeniaem Date: Wed, 17 Jul 2024 14:29:16 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FE]=20FEAT:=20=EC=97=B0=EC=B2=B4=EC=A4=91?= =?UTF-8?q?=EC=9D=BC=EB=95=8C=20=EC=97=B0=EC=9E=A5=EA=B6=8C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=8B=9C=20api=20=ED=98=B8=EC=B6=9C=20=EC=95=88?= =?UTF-8?q?=ED=95=98=EA=B3=A0=20=EB=B0=94=EB=A1=9C=20response=20modal=20?= =?UTF-8?q?=EB=9D=84=EC=9B=80#1661?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Modals/StoreModal/ExtendModal.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx b/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx index d09149bbb..b94060a0f 100644 --- a/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx +++ b/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx @@ -22,6 +22,7 @@ import { IInventoryInfo } from "@/Cabinet/components/Store/Inventory/Inventory"; import { additionalModalType, modalPropsMap } from "@/Cabinet/assets/data/maps"; import { MyCabinetInfoResponseDto } from "@/Cabinet/types/dto/cabinet.dto"; import { IItemDetail, IItemStore } from "@/Cabinet/types/dto/store.dto"; +import CabinetStatus from "@/Cabinet/types/enum/cabinet.status.enum"; import IconType from "@/Cabinet/types/enum/icon.type.enum"; import { axiosCabinetById, @@ -49,6 +50,7 @@ const ExtendModal: React.FC<{ const [itemDropdownOptions, setItemDropdownOptions] = useState< IDropdownOptions[] >([]); + const [url, setUrl] = useState(null); const [currentCabinetId] = useRecoilState(currentCabinetIdState); const [myInfo, setMyInfo] = useRecoilState(userState); const [myLentInfo, setMyLentInfo] = @@ -187,7 +189,15 @@ const ExtendModal: React.FC<{ const extensionItemUse = async (item: string) => { if (currentCabinetId === 0 || myInfo.cabinetId === null) { setHasErrorOnResponse(true); - setModalTitle("현재 대여중인 사물함이 없습니다."); + setModalTitle("연장권 사용실패"); + setModalContents("현재 대여중인 사물함이 없습니다."); + setShowResponseModal(true); + return; + } + if (myLentInfo.status === CabinetStatus.OVERDUE) { + setHasErrorOnResponse(true); + setModalTitle("연장권 사용실패"); + setModalContents(`연체 중에는 연장권을 사용하실 수 없습니다.`); setShowResponseModal(true); return; } @@ -216,6 +226,7 @@ const ExtendModal: React.FC<{ if (error.response.status === 400) { setModalTitle("연장권 사용실패"); setModalContents(noExtensionMsg); + setUrl("/store"); } else { setModalTitle(error.response?.data.message || error.data.message); } @@ -259,7 +270,7 @@ const ExtendModal: React.FC<{ modalTitle={modalTitle} modalContents={modalContents} closeModal={props.onClose} - url={"/store"} + url={url} urlTitle={"까비상점으로 이동"} /> ) : ( From bd69a179100c43e544c49578abf091cc7ba200de Mon Sep 17 00:00:00 2001 From: jnkeniaem Date: Wed, 17 Jul 2024 14:51:00 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[FE]=20REFACT:=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=EC=9C=BC=EB=A1=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=AC=EC=82=AC=EC=9A=A9#1661?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modals/StoreModal/ExtendModal.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx b/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx index b94060a0f..74a2241c7 100644 --- a/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx +++ b/frontend/src/Cabinet/components/Modals/StoreModal/ExtendModal.tsx @@ -75,8 +75,10 @@ const ExtendModal: React.FC<{ 연장권 사용은 취소할 수 없습니다.`; const extendInfoDetail = `사물함을 대여하시면 연장권 사용이 가능합니다. 연장권은 ${extensionExpiredDate} 23:59 이후 만료됩니다.`; - const noExtensionMsg = `현재 연장권을 보유하고 있지 않습니다. + const noItemMsg = `현재 연장권을 보유하고 있지 않습니다. 연장권은 까비 상점에서 구매하실 수 있습니다.`; + const overdueMsg = "연체 중에는 연장권을 사용하실 수 없습니다."; + const defaultFailureModalTitle = "연장권 사용실패"; useEffect(() => { fetchData(); @@ -86,7 +88,7 @@ const ExtendModal: React.FC<{ if (myItems?.extensionItems.length === 0) { setShowResponseModal(true); setHasErrorOnResponse(true); - setModalContents(noExtensionMsg); + setModalContents(noItemMsg); } else { setShowResponseModal(false); setHasErrorOnResponse(false); @@ -189,15 +191,15 @@ const ExtendModal: React.FC<{ const extensionItemUse = async (item: string) => { if (currentCabinetId === 0 || myInfo.cabinetId === null) { setHasErrorOnResponse(true); - setModalTitle("연장권 사용실패"); + setModalTitle(defaultFailureModalTitle); setModalContents("현재 대여중인 사물함이 없습니다."); setShowResponseModal(true); return; } if (myLentInfo.status === CabinetStatus.OVERDUE) { setHasErrorOnResponse(true); - setModalTitle("연장권 사용실패"); - setModalContents(`연체 중에는 연장권을 사용하실 수 없습니다.`); + setModalTitle(defaultFailureModalTitle); + setModalContents(overdueMsg); setShowResponseModal(true); return; } @@ -224,9 +226,12 @@ const ExtendModal: React.FC<{ } catch (error: any) { setHasErrorOnResponse(true); if (error.response.status === 400) { - setModalTitle("연장권 사용실패"); - setModalContents(noExtensionMsg); + setModalTitle(defaultFailureModalTitle); + setModalContents(noItemMsg); setUrl("/store"); + } else if (error.response.status === 403) { + setModalTitle(defaultFailureModalTitle); + setModalContents(overdueMsg); } else { setModalTitle(error.response?.data.message || error.data.message); }