From 24ca3321bb0237c3a5676d53aa8b2376d7c24bd8 Mon Sep 17 00:00:00 2001 From: moonseonghui Date: Sat, 25 Nov 2023 20:18:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FE]=20FIX:=20=EA=B3=B5=EC=9C=A0=20?= =?UTF-8?q?=EC=82=AC=EB=AC=BC=ED=95=A8=20=EB=9E=9C=EB=8D=94=EB=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CabinetListItem/CabinetListItem.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx b/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx index ebfad0ed4..286e82ddd 100644 --- a/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx +++ b/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx @@ -8,6 +8,7 @@ import { currentFloorNumberState, myCabinetInfoState, targetCabinetInfoState, + userState, } from "@/recoil/atoms"; import UnavailableModal from "@/components/Modals/UnavailableModal/UnavailableModal"; import { @@ -81,6 +82,7 @@ const CabinetListItem = (props: CabinetPreviewInfo): JSX.Element => { const currentBuilding = useRecoilValue(currentBuildingNameState); const currentFloor = useRecoilValue(currentFloorNumberState); const setCurrentFloorData = useSetRecoilState(currentFloorCabinetState); + const myInfo = useRecoilValue(userState); const selectCabinetOnClick = (status: CabinetStatus, cabinetId: number) => { if (currentCabinetId === cabinetId) { @@ -93,17 +95,21 @@ const CabinetListItem = (props: CabinetPreviewInfo): JSX.Element => { try { const { data: selectCabinetData } = await axiosCabinetById(cabinetId); setTargetCabinetInfo(selectCabinetData); - if (status !== selectCabinetData.status) { - if (myCabinetInfo.cabinetId === cabinetId) { + + if (myCabinetInfo.cabinetId === cabinetId) { + const isUserIdMatching = selectCabinetData.lents.some( + (user: { userId: number }) => user.userId === myInfo.userId + ); + if (status !== selectCabinetData.status || !isUserIdMatching) { const { data: myCabinetData } = await axiosMyLentInfo(); setMyLentInfo(myCabinetData); - } else { - const { data: floorData } = await axiosCabinetByBuildingFloor( - currentBuilding, - currentFloor - ); - setCurrentFloorData(floorData); } + } else if (status !== selectCabinetData.status) { + const { data: floorData } = await axiosCabinetByBuildingFloor( + currentBuilding, + currentFloor + ); + setCurrentFloorData(floorData); } } catch (error) { console.log(error); From 5a2ed9cca1020624b4ee306d8988eb4e308f8097 Mon Sep 17 00:00:00 2001 From: moonseonghui Date: Sat, 25 Nov 2023 20:42:56 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[FE]=20ETC:=20=EC=84=A0=ED=83=9D=ED=95=9C?= =?UTF-8?q?=20=EC=82=AC=EB=AC=BC=ED=95=A8=EC=97=90=20=EB=8C=80=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EB=82=B4=20=EC=95=84=EC=9D=B4=EB=94=94=EA=B0=80=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=B3=80=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CabinetList/CabinetListItem/CabinetListItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx b/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx index 286e82ddd..c6f736d92 100644 --- a/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx +++ b/frontend/src/components/CabinetList/CabinetListItem/CabinetListItem.tsx @@ -97,10 +97,10 @@ const CabinetListItem = (props: CabinetPreviewInfo): JSX.Element => { setTargetCabinetInfo(selectCabinetData); if (myCabinetInfo.cabinetId === cabinetId) { - const isUserIdMatching = selectCabinetData.lents.some( + const isLentedByMyUserId = selectCabinetData.lents.some( (user: { userId: number }) => user.userId === myInfo.userId ); - if (status !== selectCabinetData.status || !isUserIdMatching) { + if (status !== selectCabinetData.status || !isLentedByMyUserId) { const { data: myCabinetData } = await axiosMyLentInfo(); setMyLentInfo(myCabinetData); }