diff --git a/frontend/src/pages/MoimModifyPage/MoimModifyPage.constant.ts b/frontend/src/pages/MoimModifyPage/MoimModifyPage.constant.ts
index 3ed20b63e..72c6749e0 100644
--- a/frontend/src/pages/MoimModifyPage/MoimModifyPage.constant.ts
+++ b/frontend/src/pages/MoimModifyPage/MoimModifyPage.constant.ts
@@ -14,7 +14,7 @@ interface LabeledInputInfo {
type: string;
placeholder: string;
required: boolean;
- validate?: (value: string) => boolean;
+ validate?: (value1: string, value2?: string) => boolean;
}
const MOIM_INPUT_INFOS: LabeledInputInfo[] = [
@@ -24,7 +24,7 @@ const MOIM_INPUT_INFOS: LabeledInputInfo[] = [
type: 'text',
placeholder: `${POLICES.minimumTitleLength}자 이상 ${POLICES.maximumTitleLength}자 이하로 입력해주세요`,
required: true,
- validate: validateTitle, // string 타입
+ validate: validateTitle,
},
{
name: 'date',
@@ -32,7 +32,7 @@ const MOIM_INPUT_INFOS: LabeledInputInfo[] = [
type: 'date',
placeholder: '현재 시간 이후로 설정해주세요',
required: false,
- validate: validateDate, // string 타입
+ validate: validateDate,
},
{
name: 'time',
@@ -40,7 +40,7 @@ const MOIM_INPUT_INFOS: LabeledInputInfo[] = [
type: 'time',
placeholder: '현재 시간 이후로 설정해주세요',
required: false,
- validate: validateTime, // string 타입
+ validate: validateTime,
},
{
name: 'place',
diff --git a/frontend/src/pages/MoimModifyPage/MoimModifyPage.tsx b/frontend/src/pages/MoimModifyPage/MoimModifyPage.tsx
index b880e08d3..f6d32e31c 100644
--- a/frontend/src/pages/MoimModifyPage/MoimModifyPage.tsx
+++ b/frontend/src/pages/MoimModifyPage/MoimModifyPage.tsx
@@ -43,16 +43,35 @@ export default function MoimModifyPage() {
- {MOIM_INPUT_INFOS.map((info) =>
- info.type === 'textarea' ? (
-
- ) : (
+ {MOIM_INPUT_INFOS.map((info) => {
+ if (info.type === 'textarea') {
+ return (
+
+ );
+ } else if (info.type === 'time') {
+ return (
+ {
+ return info?.validate
+ ? info.validate(time, inputData['date'])
+ : true;
+ }}
+ />
+ );
+ }
+
+ return (
- ),
- )}
+ );
+ })}
diff --git a/frontend/src/pages/MoimModifyPage/MoimModifyPage.util.ts b/frontend/src/pages/MoimModifyPage/MoimModifyPage.util.ts
index 694859cc7..77359d7aa 100644
--- a/frontend/src/pages/MoimModifyPage/MoimModifyPage.util.ts
+++ b/frontend/src/pages/MoimModifyPage/MoimModifyPage.util.ts
@@ -13,7 +13,7 @@ export const validateDate = (date: string) => {
return date >= nowDateYyyymmdd && POLICIES.yyyymmddDashRegex.test(date);
};
-export const validateTime = (time: string) => {
+export const validateTime = (time: string, date?: string) => {
if (time === '') {
return true;
}
@@ -21,18 +21,24 @@ export const validateTime = (time: string) => {
return false;
}
- const now = new Date();
- const [inputHour, inputMinute] = time.split(':').map(Number);
- const inputTime = new Date(
- now.getFullYear(),
- now.getMonth(),
- now.getDate(),
- inputHour,
- inputMinute,
- );
+ console.log(date);
- if (inputTime < now) {
- return false;
+ if (date !== '') {
+ const dates = date?.split('-').map(Number);
+
+ const now = new Date();
+ const [inputHour, inputMinute] = time.split(':').map(Number);
+ const inputTime = new Date(
+ dates?.[0] ?? now.getFullYear(), // 년도
+ (dates?.[1] ?? now.getMonth() + 1) - 1, // 월
+ dates?.[2] ?? now.getDate(), // 일
+ inputHour,
+ inputMinute,
+ );
+
+ if (inputTime < now) {
+ return false;
+ }
}
return true;
};
@@ -48,9 +54,9 @@ export const validatePlace = (place: string) => {
};
export const validateMaxPeople = (maxPeople: number | string) => {
if (typeof maxPeople === 'string') {
- maxPeople = Number(maxPeople); // string을 number로 변환
+ maxPeople = Number(maxPeople);
if (isNaN(maxPeople)) {
- return false; // 변환이 실패하면 false 반환
+ return false;
}
}