From 874815a2e8fb05e006e419a6a5acfefba5f4a874 Mon Sep 17 00:00:00 2001 From: stakbucks Date: Tue, 12 Dec 2023 13:56:06 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20=EC=A7=91=20=EB=82=B4=EB=B6=80=20?= =?UTF-8?q?=EA=B0=80=EA=B5=AC=EB=93=A4=EC=9D=84=20=EB=AF=B8=EC=85=98?= =?UTF-8?q?=EC=95=84=EC=9D=B4=EB=94=94=20=EC=98=A4=EB=A6=84=EC=B0=A8?= =?UTF-8?q?=EC=88=9C=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EB=A0=AC=ED=95=9C=20?= =?UTF-8?q?=EB=92=A4=20=EB=B0=B0=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/House/Inside/Inside.tsx | 16 +++++++++++----- .../MissionFurniturePreview.tsx | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pages/House/Inside/Inside.tsx b/src/pages/House/Inside/Inside.tsx index 2ede9f4..7c80f09 100644 --- a/src/pages/House/Inside/Inside.tsx +++ b/src/pages/House/Inside/Inside.tsx @@ -65,11 +65,17 @@ export default function Inside() { }); // 가구 레이어 이미지를 가져오는 string형식으로 리턴 - const furnitures = data?.completedMissions?.map( - (mission) => - FurnitureLayer[`FurnitureLayer${mission.missionCompleteFurnitureId}`], - ); - + const furnitures = data?.completedMissions + ?.sort( + (a, b) => + +a.missionCompleteFurnitureId.toString().slice(0, -1) - + +b.missionCompleteFurnitureId.toString().slice(0, -1), + ) + .map( + (mission: ICompletedMission) => + FurnitureLayer[`FurnitureLayer${mission.missionCompleteFurnitureId}`], + ); + console.log(data?.completedMissions); const getMissionIdFromFurnitureid = (furnitureId: number) => { const stringId = `${furnitureId}`; if (stringId.length === 2) { diff --git a/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx b/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx index ab1a79b..cb84b7c 100644 --- a/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx +++ b/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx @@ -110,8 +110,8 @@ export default function MissionFurniturePreview() { margin="23px 0 0 0" imgs={[ Wallpapers[`Wallpaper${wallpaperId}`], - ...furnitureImgs, selectedFurnitureImage && selectedFurnitureImage, + ...furnitureImgs, ]} /> From 4c89811a308ebef7c8d4b50f4308c2c192e32223 Mon Sep 17 00:00:00 2001 From: stakbucks Date: Tue, 12 Dec 2023 14:07:35 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20=EB=AF=B8=EC=85=98=20=EC=88=98?= =?UTF-8?q?=ED=96=89=20=EC=8B=9C=20=EA=B0=80=EA=B5=AC=20=EB=B0=B0=EC=B9=98?= =?UTF-8?q?=20=EB=AF=B8=EB=A6=AC=EB=B3=B4=EA=B8=B0=20=EC=84=A0=ED=83=9D=20?= =?UTF-8?q?=EC=8B=9C=20=EA=B0=80=EA=B5=AC=20=EB=AF=B8=EC=85=98=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EB=94=94=20=EC=98=A4=EB=A6=84=EC=B0=A8=EC=88=9C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MissionFurniturePreview.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx b/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx index cb84b7c..ac43235 100644 --- a/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx +++ b/src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx @@ -20,6 +20,7 @@ import {useAllCompletedMissions} from '@/hooks/useAllCompletedMissions'; import useTodayMission from '@/hooks/useTodayMission'; import {userInfoAtom} from '@/atoms/loginStateAtom'; import Spinner from '@/components/Spinner/Spinner'; +import {ICompletedMission} from '@/interfaces/mission'; export default function MissionFurniturePreview() { // 모달 상태관리 @@ -74,7 +75,8 @@ export default function MissionFurniturePreview() { openMissionArriveModal(); }); const {missionId} = useTodayMission(userId); - const {furnitureImgs, wallpaperId} = useAllCompletedMissions(userId); + const {furnitureImgs, wallpaperId, completedMissions} = + useAllCompletedMissions(userId); // 가구 고르기 버튼 클릭 const handleFurnitureClick = ( @@ -89,6 +91,18 @@ export default function MissionFurniturePreview() { missionCompleteFurnitureId: +`${missionId}${furnitureNum}`, })); }; + const furnitures = completedMissions + ?.sort( + (a, b) => + +a.missionCompleteFurnitureId.toString().slice(0, -1) - + +b.missionCompleteFurnitureId.toString().slice(0, -1), + ) + .map( + (mission: ICompletedMission) => + FurnitureLayer[`FurnitureLayer${mission.missionCompleteFurnitureId}`], + ); + furnitures.splice(missionId - 1, 0, selectedFurnitureImage); + console.log(furnitures); const queryClient = useQueryClient(); @@ -108,11 +122,7 @@ export default function MissionFurniturePreview() { width={355} height={533} margin="23px 0 0 0" - imgs={[ - Wallpapers[`Wallpaper${wallpaperId}`], - selectedFurnitureImage && selectedFurnitureImage, - ...furnitureImgs, - ]} + imgs={[Wallpapers[`Wallpaper${wallpaperId}`], ...furnitures]} />