Skip to content

Commit 0e62b41

Browse files
authored
fix(mobile): 모바일로 확인했을 때 ui가 깨지는 이슈를 해결합니다. (#118)
1 parent 3a369ed commit 0e62b41

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

apps/mobile/app/select-date/page.tsx

+16-15
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,32 @@ export default function page() {
99
const MAX_LENGTH = 16;
1010

1111
const [planName, setPlanName] = useState("");
12-
const [isDisabledNextBtn, setIsDisabledNextBtn] = useState(true);
12+
const [isDateSelected, setIsDateSelected] = useState(false);
13+
const isRightName = planName.length > 0 && planName.length < 17;
14+
const isActiveBtn = isRightName && isDateSelected;
1315

1416
const handleChangeInput = (e: React.ChangeEvent<HTMLInputElement>) => {
1517
const { value } = e.currentTarget;
1618
setPlanName(value);
1719
};
1820

19-
const handleDisabledNextBtn = (isDisabled: boolean) => {
20-
setIsDisabledNextBtn(isDisabled);
21+
const handleSelectDate = (isSelected: boolean) => {
22+
setIsDateSelected(isSelected);
2123
};
2224

2325
return (
2426
<div className="flex flex-col justify-between h-[calc(100dvh-11.2rem)]">
25-
<div>
26-
<TextField
27-
inputSize="mobile"
28-
placeholder={PLACE_HOLDER}
29-
value={planName}
30-
maxLength={MAX_LENGTH}
31-
onChange={handleChangeInput}
32-
/>
33-
<SelectDateCalendar handleDisabledNextBtn={handleDisabledNextBtn} />
34-
</div>
35-
36-
<Button color={isDisabledNextBtn ? "cancel" : "default"} font="default" size="mobile">
27+
<TextField
28+
inputSize="mobile"
29+
placeholder={PLACE_HOLDER}
30+
value={planName}
31+
maxLength={MAX_LENGTH}
32+
onChange={handleChangeInput}
33+
/>
34+
35+
<SelectDateCalendar handleSelectDate={handleSelectDate} />
36+
37+
<Button color={isActiveBtn ? "default" : "disabled"} font="default" size="mobile" disabled={!isActiveBtn}>
3738
다음으로
3839
</Button>
3940
</div>

apps/mobile/components/select-date/SelectDateCalendar.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { DAY, MONTH_NAMES } from "../../contants/calendarConst";
66
import { getCalendarDate } from "../../utils/getCalendarDate";
77

88
function SelectDateCalendar({
9-
handleDisabledNextBtn,
9+
handleSelectDate,
1010
}: {
11-
handleDisabledNextBtn: (isDisabled: boolean) => void;
11+
handleSelectDate: (isSelected: boolean) => void;
1212
}) {
1313
const [year, setYear] = useState(new Date().getFullYear());
1414
const [month, setMonth] = useState(new Date().getMonth() + 1);
@@ -173,18 +173,12 @@ function SelectDateCalendar({
173173
];
174174

175175
setSelectedDate(updatedDate);
176-
177-
if (updatedDate.length === 0) handleDisabledNextBtn(true);
178-
else {
179-
if (selectedDateNum.current < 14) handleDisabledNextBtn(false);
180-
}
176+
handleSelectDate(false);
181177
} else {
182178
const lastDate = selectedDate[selectedDate.length - 1];
183179
const isStartDateNull = lastDate && lastDate.startDate === 0 && lastDate.endDate !== 0;
184180
const isEndDateNull = lastDate && lastDate.startDate !== 0 && lastDate.endDate === 0;
185181

186-
handleDisabledNextBtn(false);
187-
188182
// 선택된 날짜가 없는 경우
189183
if (selectedDate.length === 0) {
190184
setSelectedDate([
@@ -197,6 +191,7 @@ function SelectDateCalendar({
197191
endDate: 0,
198192
},
199193
]);
194+
handleSelectDate(false);
200195
}
201196

202197
// 시작 날짜와 끝나는 날짜 중 하나가 선택되어 있는 경우
@@ -217,9 +212,11 @@ function SelectDateCalendar({
217212
month: startMonth,
218213
date: startDate,
219214
});
215+
handleSelectDate(true);
220216
if (selectedDateNum.current >= 14) {
217+
// 선택한 날짜가 14일을 넘었을 때 동작하는 플로우 추가 시 삭제 예정
221218
alert("14일 넘음");
222-
handleDisabledNextBtn(true);
219+
handleSelectDate(false);
223220
}
224221
}
225222

@@ -236,9 +233,11 @@ function SelectDateCalendar({
236233
month: endMonth,
237234
date: endDate,
238235
});
236+
handleSelectDate(true);
239237
if (selectedDateNum.current >= 14) {
238+
// 선택한 날짜가 14일을 넘었을 때 동작하는 플로우 추가 시 삭제 예정
240239
alert("14일 넘음");
241-
handleDisabledNextBtn(true);
240+
handleSelectDate(false);
242241
}
243242
}
244243
}
@@ -256,12 +255,13 @@ function SelectDateCalendar({
256255
endDate: 0,
257256
},
258257
]);
258+
handleSelectDate(false);
259259
}
260260
}
261261
};
262262

263263
return (
264-
<article className="flex flex-col mt-[5.6rem]">
264+
<article className="flex flex-col h-[38.3rem] mb-[2rem]">
265265
<header className="flex items-center justify-center mb-[2.2rem]">
266266
<button type="button" onClick={() => handleClickArrow("left")}>
267267
<MobileIconArrowLeftGray />
@@ -339,7 +339,7 @@ function SelectDateCalendar({
339339
{((isRightSelection && isClickedNum) || isInRange) && (
340340
<span
341341
className={`absolute top-0 ${isStartDate ? "right-0" : "left-0"} ${
342-
isClickedNum ? "w-[2.45rem]" : "w-[4.9rem]"
342+
isClickedNum ? "w-[2.45rem]" : "w-[100%]"
343343
} h-[3.6rem] bg-sub-1`}
344344
/>
345345
)}

0 commit comments

Comments
 (0)