Skip to content

Commit

Permalink
Merge pull request #36 from My-Cookie-House/hotfix
Browse files Browse the repository at this point in the history
집 내부 가구들을 미션아이디 오름차순으로 정렬한 뒤 배치
  • Loading branch information
minseong0324 authored Dec 12, 2023
2 parents 5cde9b8 + 4c89811 commit c5536f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/pages/House/Inside/Inside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 16 additions & 6 deletions src/pages/MissionFurniturePreview/MissionFurniturePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
// 모달 상태관리
Expand Down Expand Up @@ -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 = (
Expand All @@ -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();

Expand All @@ -108,11 +122,7 @@ export default function MissionFurniturePreview() {
width={355}
height={533}
margin="23px 0 0 0"
imgs={[
Wallpapers[`Wallpaper${wallpaperId}`],
...furnitureImgs,
selectedFurnitureImage && selectedFurnitureImage,
]}
imgs={[Wallpapers[`Wallpaper${wallpaperId}`], ...furnitures]}
/>
</S.FurnitureLayerWrapper>
<Modal
Expand Down

0 comments on commit c5536f1

Please sign in to comment.