Skip to content

Commit

Permalink
Merge pull request #1431 from innovationacademy-kr/fe/dev/fix_share_s…
Browse files Browse the repository at this point in the history
…ession_rendering#1425

[FE] FIX: 공유 사물함 랜더링 추가문제 해결
  • Loading branch information
seong-hui authored Nov 25, 2023
2 parents 09ddb71 + 5a2ed9c commit 31daacb
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
currentFloorNumberState,
myCabinetInfoState,
targetCabinetInfoState,
userState,
} from "@/recoil/atoms";
import UnavailableModal from "@/components/Modals/UnavailableModal/UnavailableModal";
import {
Expand Down Expand Up @@ -81,6 +82,7 @@ const CabinetListItem = (props: CabinetPreviewInfo): JSX.Element => {
const currentBuilding = useRecoilValue<string>(currentBuildingNameState);
const currentFloor = useRecoilValue<number>(currentFloorNumberState);
const setCurrentFloorData = useSetRecoilState(currentFloorCabinetState);
const myInfo = useRecoilValue(userState);

const selectCabinetOnClick = (status: CabinetStatus, cabinetId: number) => {
if (currentCabinetId === cabinetId) {
Expand All @@ -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 isLentedByMyUserId = selectCabinetData.lents.some(
(user: { userId: number }) => user.userId === myInfo.userId
);
if (status !== selectCabinetData.status || !isLentedByMyUserId) {
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);
Expand Down

0 comments on commit 31daacb

Please sign in to comment.