From ec2a01b7df4948dff89114bc8d546e7eb09338cd Mon Sep 17 00:00:00 2001 From: jaeml06 Date: Mon, 26 Aug 2024 21:55:41 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=ED=98=84=EC=9E=AC=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=EA=B3=BC=20=EC=9E=85=EB=A0=A5=20=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=EC=9D=84=20=EB=B9=84=EA=B5=90=ED=95=98=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MoimCreationPage/MoimCreationPage.util.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.ts b/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.ts index b91d25e9f..c6335041d 100644 --- a/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.ts +++ b/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.ts @@ -19,7 +19,24 @@ export const validateTime = (time: string) => { if (time === '') { return true; } - return POLICIES.hhmmRegex.test(time); + if (!POLICIES.hhmmRegex.test(time)) { + 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, + ); + + if (inputTime < now) { + return false; + } + return true; }; export const validatePlace = (place: string) => { From fb4945ff146f0a4186a37ed95c9aaad1714bda1c Mon Sep 17 00:00:00 2001 From: jaeml06 Date: Mon, 26 Aug 2024 21:56:10 +0900 Subject: [PATCH 2/4] =?UTF-8?q?test:=20=ED=98=84=EC=9E=AC=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EB=B9=84=EA=B5=90=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EC=97=90=20=EB=94=B0=EB=A5=B8=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MoimCreationPage.util.test.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.test.tsx b/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.test.tsx index 143008333..2aef62806 100644 --- a/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.test.tsx +++ b/frontend/src/pages/MoimCreationPage/MoimCreationPage.util.test.tsx @@ -23,7 +23,7 @@ describe('Validation Tests', () => { describe('validateDate', () => { beforeAll(() => { jest.useFakeTimers(); - jest.setSystemTime(new Date('2024-07-23T00:00:00Z')); + jest.setSystemTime(new Date('2024-07-23T10:00:00Z')); }); afterAll(() => { @@ -44,9 +44,17 @@ describe('Validation Tests', () => { }); describe('validateTime', () => { + beforeAll(() => { + jest.useFakeTimers(); + jest.setSystemTime(new Date('2024-07-23T10:00:00')); + }); + + afterAll(() => { + jest.useRealTimers(); + }); it('00:00 형식이어야 true를 반환한다.', () => { - expect(validateTime('12:34')).toBe(true); - expect(validateTime('00:00')).toBe(true); + expect(validateTime('09:59')).toBe(false); // 현재 시간보다 이전 + expect(validateTime('10:01')).toBe(true); // 현재 시간보다 이후 expect(validateTime('23:59')).toBe(true); }); From 4450f27ea2db989754dcdee4ac570ba66595b9dc Mon Sep 17 00:00:00 2001 From: jaeml06 Date: Mon, 26 Aug 2024 22:07:14 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EC=97=90=EB=9F=AC=20=EC=83=81?= =?UTF-8?q?=ED=99=A9=EC=9D=BC=EB=95=8C=20alert=EC=B0=BD=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/queryClient.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/queryClient.ts b/frontend/src/queryClient.ts index 4483e86f8..d2bcbef8b 100644 --- a/frontend/src/queryClient.ts +++ b/frontend/src/queryClient.ts @@ -34,6 +34,7 @@ const handleApiError = (error: Error) => { Sentry.captureException(error); console.log(error); if (error instanceof ApiError) { + console.log(1); if (error.status === 401) { removeToken(); window.location.href = ROUTES.home; @@ -49,10 +50,13 @@ const handleApiError = (error: Error) => { if (error.message === '모임이 존재하지 않습니다.') { window.location.href = GET_ROUTES.nowDarakbang.main(); return; + } else { + alert(error.message); } } else { alert(error instanceof Error ? error.message : 'An error occurred'); } + console.log(3); }; export default createQueryClient; From 56b8de0db9a5f10db0d119157d7fa1bd4a7fbd5c Mon Sep 17 00:00:00 2001 From: jaeml06 Date: Sat, 31 Aug 2024 21:26:05 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20console.log=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/queryClient.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontend/src/queryClient.ts b/frontend/src/queryClient.ts index d2bcbef8b..a23d171f7 100644 --- a/frontend/src/queryClient.ts +++ b/frontend/src/queryClient.ts @@ -32,9 +32,7 @@ const createQueryClient = () => { const handleApiError = (error: Error) => { Sentry.captureException(error); - console.log(error); if (error instanceof ApiError) { - console.log(1); if (error.status === 401) { removeToken(); window.location.href = ROUTES.home; @@ -56,7 +54,6 @@ const handleApiError = (error: Error) => { } else { alert(error instanceof Error ? error.message : 'An error occurred'); } - console.log(3); }; export default createQueryClient;