Skip to content

Commit bc66732

Browse files
committed
✨ feat(#141): 행성 관리 홈 고정 및 삭제 BottomSheet 기능 추가
1 parent 7951d3e commit bc66732

2 files changed

Lines changed: 36 additions & 21 deletions

File tree

src/app/planet/manage/page.tsx

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,19 @@ const PlanetManagePage = () => {
8484
};
8585

8686
/* BottomSheet 관련 함수 */
87+
useEffect(() => {
88+
if (isBottomUp) {
89+
setShowBottom(true);
90+
} else {
91+
setTimeout(() => {
92+
setShowBottom(false);
93+
}, 490);
94+
}
95+
}, [isBottomUp]);
96+
8797
const handleShowBottom = (id: string) => {
8898
setSelectedId(id);
89-
setShowBottom(true);
99+
setIsBottomUp(true);
90100
};
91101

92102
const handleBottomUpChange = (state: boolean) => {
@@ -95,23 +105,31 @@ const PlanetManagePage = () => {
95105

96106
/* 홈(메인) 행성 고정 */
97107
const handleFixMainPlanet = () => {
108+
const selectedPlanet = planets?.filter((planet) =>
109+
selectedId.includes(planet.spaceId)
110+
);
111+
98112
/* TODO: 선택 행성 (selectedId) 메인 행성으로 변경 API 연동 */
99-
setShowBottom(false);
113+
114+
setIsBottomUp(false);
115+
showToast(`${selectedPlanet[0]?.spaceName} 행성을 홈으로 고정했어요`, {
116+
icon: false,
117+
close: false,
118+
bottom: '65px'
119+
});
100120
};
101121

102122
/* 행성 삭제 관련 함수 */
103123
const handleDeletePlanet = () => {
104-
setShowBottom(false);
124+
setIsBottomUp(false);
105125
setConfirmDeleteModal(true);
106126
};
107127

108128
const handleConfirmDeletePlanet = async () => {
109129
if (selectedId) {
110-
const smallestIndexPlanet = planets
111-
?.filter((planet) => selectedId.includes(planet.spaceId))
112-
?.reduce((prev, curr) =>
113-
planets.indexOf(prev) < planets.indexOf(curr) ? prev : curr
114-
);
130+
const selectedPlanet = planets?.filter((planet) =>
131+
selectedId.includes(planet.spaceId)
132+
);
115133

116134
/* 행성 삭제하기 */
117135
try {
@@ -124,15 +142,15 @@ const PlanetManagePage = () => {
124142
) || []
125143
);
126144
await fetchSpaceList();
127-
setShowBottom(false);
145+
setIsBottomUp(false);
128146
} catch (error) {
129147
console.error('행성 삭제 실패:', error);
130148
}
131149

132150
setConfirmDeleteModal(false);
133151
setDragMode(false);
134152
showToast(
135-
`${smallestIndexPlanet?.spaceName} 행성과 등록된 편지들이 함께 삭제 되었어요`,
153+
`${selectedPlanet[0]?.spaceName} 행성과 등록된 편지들이 함께 삭제되었어요`,
136154
{
137155
icon: false,
138156
close: false,
@@ -203,7 +221,6 @@ const PlanetManagePage = () => {
203221
<PlanetBoxList
204222
ref={provided.innerRef}
205223
{...provided.droppableProps}
206-
$marginBottom={dragMode}
207224
>
208225
{planets?.map((planet, index) => (
209226
<Draggable
@@ -285,7 +302,7 @@ const Layout = styled.div`
285302
display: flex;
286303
flex-direction: column;
287304
overflow-x: hidden;
288-
/* overflow-y: hidden; */
305+
overflow-y: hidden;
289306
gap: 7px;
290307
padding: 20px;
291308
background-color: ${theme.colors.bg};
@@ -334,17 +351,12 @@ const Divider = styled.div`
334351
margin-bottom: 22px;
335352
`;
336353

337-
const PlanetBoxList = styled.div<{ $marginBottom: boolean }>`
354+
const PlanetBoxList = styled.div`
338355
height: 100%;
339356
display: flex;
340357
flex-direction: column;
341358
overflow-y: scroll;
342-
343-
${({ $marginBottom }) =>
344-
$marginBottom &&
345-
css`
346-
margin-bottom: 100px;
347-
`}
359+
padding-bottom: 50px;
348360
349361
::-webkit-scrollbar {
350362
display: none;
@@ -354,11 +366,13 @@ const PlanetBoxList = styled.div<{ $marginBottom: boolean }>`
354366
`;
355367

356368
const BottomSheetContent = styled.div`
369+
height: 100%;
357370
display: flex;
358371
flex-direction: column;
359-
justify-content: center;
372+
justify-content: flex-end;
360373
align-items: flex-start;
361374
gap: 24px;
375+
margin-top: 20px;
362376
`;
363377

364378
const BottomSheetButton = styled.button`

src/components/common/BottomSheet.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const SheetBackground = styled(motion.div)<{ $sheetHeight: number }>`
138138
const BottomHeader = styled.div`
139139
height: 56px;
140140
cursor: grab;
141-
padding-top: 12px;
141+
padding-top: 19px;
142142
user-select: none;
143143
`;
144144

@@ -160,6 +160,7 @@ const SheetContentWrapper = styled.div`
160160

161161
const SheetContent = styled.div`
162162
width: 100%;
163+
height: 100%;
163164
display: flex;
164165
flex-direction: column;
165166
`;

0 commit comments

Comments
 (0)