From 78b0308e25859baa6626185835c0f2e591dee8d5 Mon Sep 17 00:00:00 2001 From: jllee000 Date: Sat, 13 Sep 2025 01:46:18 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=EC=98=A8=EB=B3=B4=EB=94=A9=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onBoarding/components/funnel/MainCard.tsx | 17 ++++++++++++++++- apps/client/src/shared/apis/axios.ts | 11 +++++++++++ apps/client/src/shared/apis/queries.ts | 15 ++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx b/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx index 7126d761..bfe9bafe 100644 --- a/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx +++ b/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx @@ -6,6 +6,7 @@ import AlarmStep from './step/AlarmStep'; import MacStep from './step/MacStep'; import FinalStep from './step/FinalStep'; import { cva } from 'class-variance-authority'; +import { usePostSignUp } from '@shared/apis/queries'; const stepProgress = [{ progress: 30 }, { progress: 60 }, { progress: 100 }]; const variants = { @@ -36,6 +37,8 @@ const MainCard = () => { const [direction, setDirection] = useState(0); const [alarmSelected, setAlarmSelected] = useState<1 | 2 | 3>(1); const [isMac, setIsMac] = useState(false); + // api 구간 + const {mutate:postSignData} = usePostSignUp(); useEffect(() => { const ua = navigator.userAgent.toLowerCase(); @@ -70,7 +73,19 @@ const MainCard = () => { setDirection(1); setStep((prev) => prev + 1); } else if (step === 5) { - window.location.href = '/'; + postSignData({ + "email": "tesdfdfsst@gmail.com", + "remindDefault": "08:00", + "fcmToken": "adlfdjlajlkadfsjlkfdsdfsdfsdfsdfsa" + }, + { + onSuccess:()=>{ + window.location.href = '/'; + } + } + ) + + } }; diff --git a/apps/client/src/shared/apis/axios.ts b/apps/client/src/shared/apis/axios.ts index c7175346..13598ef8 100644 --- a/apps/client/src/shared/apis/axios.ts +++ b/apps/client/src/shared/apis/axios.ts @@ -20,3 +20,14 @@ export const getAcorns = async () => { }); return data.data; }; + +export interface postSignUpRequest { + email: string, + remindDefault: string, + fcmToken: string +} + +export const postSignUp = async (data: postSignUpRequest) => { + const response = await apiRequest.post('/api/v1/auth/signup', {data}); + return response.data; +}; \ No newline at end of file diff --git a/apps/client/src/shared/apis/queries.ts b/apps/client/src/shared/apis/queries.ts index 45bcc054..bdb7ff04 100644 --- a/apps/client/src/shared/apis/queries.ts +++ b/apps/client/src/shared/apis/queries.ts @@ -1,5 +1,5 @@ import { useMutation, useQuery, UseQueryResult } from '@tanstack/react-query'; -import { getDashboardCategories, postCategory } from '@shared/apis/axios'; +import { getDashboardCategories, postCategory, postSignUp, postSignUpRequest } from '@shared/apis/axios'; import { AxiosError } from 'axios'; import { DashboardCategoriesResponse, AcornsResponse } from '@shared/types/api'; import { getAcorns } from './axios'; @@ -26,3 +26,16 @@ export const useGetArcons = (): UseQueryResult => { queryFn: () => getAcorns(), }); }; + +export const usePostSignUp = () =>{ + return useMutation({ + mutationFn: (data: postSignUpRequest) => postSignUp(data), + onSuccess: (data) => { + console.log("회원가입 성공:", data); + }, + onError: (error) => { + console.error("회원가입 실패:", error); + + }, + }); +} \ No newline at end of file From 1e6bc1a71b832263528accd7e119d77e84fdc6fd Mon Sep 17 00:00:00 2001 From: jllee000 Date: Sat, 13 Sep 2025 02:06:36 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=ED=83=80=EC=9E=84=ED=94=BC?= =?UTF-8?q?=EC=BB=A4=20=20=EC=8B=9C=EA=B0=84=20=ED=8F=AC=EB=A7=B7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onBoarding/components/funnel/AlarmBox.tsx | 3 ++- .../onBoarding/components/funnel/MainCard.tsx | 12 ++++++--- .../onBoarding/utils/formatRemindTime.ts | 26 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 apps/client/src/pages/onBoarding/utils/formatRemindTime.ts diff --git a/apps/client/src/pages/onBoarding/components/funnel/AlarmBox.tsx b/apps/client/src/pages/onBoarding/components/funnel/AlarmBox.tsx index 0aaffbbd..b29aad77 100644 --- a/apps/client/src/pages/onBoarding/components/funnel/AlarmBox.tsx +++ b/apps/client/src/pages/onBoarding/components/funnel/AlarmBox.tsx @@ -2,6 +2,7 @@ import { cva } from 'class-variance-authority'; import TimePicker from '../timePicker/TimePicker'; import { AlarmsType } from '@constants/alarms'; import { useState } from 'react'; +import { normalizeTime } from '@pages/onBoarding/utils/formatRemindTime'; interface AlarmBoxProps { select: 1 | 2 | 3; isDisabled: boolean; @@ -57,7 +58,7 @@ const AlarmBox = ({ select, isDisabled, onClick }: AlarmBoxProps) => { {select === 3 && isDisabled && ( <> {AlarmsType[2].time && ( -

{AlarmsType[2].time}

+

{normalizeTime(AlarmsType[2].time)}

)} {showPicker && ( diff --git a/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx b/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx index bfe9bafe..16fd887e 100644 --- a/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx +++ b/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx @@ -8,7 +8,8 @@ import FinalStep from './step/FinalStep'; import { cva } from 'class-variance-authority'; import { usePostSignUp } from '@shared/apis/queries'; const stepProgress = [{ progress: 30 }, { progress: 60 }, { progress: 100 }]; - +import { AlarmsType } from '@constants/alarms'; +import { normalizeTime } from '@pages/onBoarding/utils/formatRemindTime'; const variants = { slideIn: (direction: number) => ({ x: direction > 0 ? 200 : -200, @@ -65,17 +66,22 @@ const MainCard = () => { } }; +const [remindTime, setRemindTime] = useState('09:00'); const nextStep = () => { + console.log(step) if (step === 3) { - // 이거 이후에 api 붙일 자리 표시임! console.log('선택된 알람:', AlarmsType[alarmSelected - 1].time); + // 이거 이후에 api 붙일 자리 표시임! + const raw = AlarmsType[alarmSelected - 1].time; + setRemindTime(normalizeTime(raw)) } if (step < 5) { + setDirection(1); setStep((prev) => prev + 1); } else if (step === 5) { postSignData({ "email": "tesdfdfsst@gmail.com", - "remindDefault": "08:00", + "remindDefault": remindTime, "fcmToken": "adlfdjlajlkadfsjlkfdsdfsdfsdfsdfsa" }, { diff --git a/apps/client/src/pages/onBoarding/utils/formatRemindTime.ts b/apps/client/src/pages/onBoarding/utils/formatRemindTime.ts new file mode 100644 index 00000000..b5b0794c --- /dev/null +++ b/apps/client/src/pages/onBoarding/utils/formatRemindTime.ts @@ -0,0 +1,26 @@ +export function normalizeTime(input: string): string { + let hours = 0; + let minutes = 0; + + const ampmMatch = input.match(/(AM|PM)\s?(\d{1,2}):(\d{1,2})/i); + if (ampmMatch) { + const [, ampm, h, m] = ampmMatch; + hours = parseInt(h, 10); + minutes = parseInt(m, 10); + + if (ampm.toUpperCase() === "PM" && hours < 12) { + hours += 12; + } + if (ampm.toUpperCase() === "AM" && hours === 12) { + hours = 0; // 12 AM → 00시 + } + } else { + const [h, m] = input.split(":"); + hours = parseInt(h, 10); + minutes = parseInt(m, 10); + } + + const hh = String(hours).padStart(2, "0"); + const mm = String(minutes).padStart(2, "0"); + return `${hh}:${mm}`; +} \ No newline at end of file From 19b0081888e9167cfded74bbb185b3f3d7449f9a Mon Sep 17 00:00:00 2001 From: jllee000 Date: Sat, 13 Sep 2025 02:14:26 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EB=A1=9C?= =?UTF-8?q?=EC=BB=AC=EC=8A=A4=ED=86=A0=EB=A6=AC=EC=A7=80=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 --- apps/client/src/shared/apis/queries.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/client/src/shared/apis/queries.ts b/apps/client/src/shared/apis/queries.ts index bdb7ff04..77aea1db 100644 --- a/apps/client/src/shared/apis/queries.ts +++ b/apps/client/src/shared/apis/queries.ts @@ -27,15 +27,21 @@ export const useGetArcons = (): UseQueryResult => { }); }; -export const usePostSignUp = () =>{ +export const usePostSignUp = () => { return useMutation({ mutationFn: (data: postSignUpRequest) => postSignUp(data), onSuccess: (data) => { + // postSignUp에서 axios 같은 걸 리턴한다고 가정 + const newToken = data?.data?.token || data?.token; + + if (newToken) { + localStorage.setItem("token", newToken); + } + console.log("회원가입 성공:", data); }, onError: (error) => { console.error("회원가입 실패:", error); - }, }); -} \ No newline at end of file +}; From 205b66f5b750303963b9cd57540a9608efd36afd Mon Sep 17 00:00:00 2001 From: jllee000 Date: Sat, 13 Sep 2025 02:14:28 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EB=A1=9C?= =?UTF-8?q?=EC=BB=AC=EC=8A=A4=ED=86=A0=EB=A6=AC=EC=A7=80=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 --- apps/client/src/shared/apis/queries.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/client/src/shared/apis/queries.ts b/apps/client/src/shared/apis/queries.ts index 77aea1db..1533d8ff 100644 --- a/apps/client/src/shared/apis/queries.ts +++ b/apps/client/src/shared/apis/queries.ts @@ -31,7 +31,6 @@ export const usePostSignUp = () => { return useMutation({ mutationFn: (data: postSignUpRequest) => postSignUp(data), onSuccess: (data) => { - // postSignUp에서 axios 같은 걸 리턴한다고 가정 const newToken = data?.data?.token || data?.token; if (newToken) { From 7dd8a8c36f2ff702f3994fac2f65ce743851d16e Mon Sep 17 00:00:00 2001 From: jllee000 Date: Sat, 13 Sep 2025 02:24:05 +0900 Subject: [PATCH 5/6] =?UTF-8?q?api:=20=EB=A6=AC=EB=A7=88=EC=9D=B8=EB=93=9C?= =?UTF-8?q?=20=ED=83=80=EC=9E=84=20NAN=EC=88=98=EC=A0=95=20=EB=B0=8F=20dat?= =?UTF-8?q?a=20=EA=B0=9D=EC=B2=B4=20=EB=AC=B6=EC=9D=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/onBoarding/components/funnel/MainCard.tsx | 7 ++++--- apps/client/src/shared/apis/axios.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx b/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx index 16fd887e..b63cc46a 100644 --- a/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx +++ b/apps/client/src/pages/onBoarding/components/funnel/MainCard.tsx @@ -71,14 +71,15 @@ const [remindTime, setRemindTime] = useState('09:00'); console.log(step) if (step === 3) { // 이거 이후에 api 붙일 자리 표시임! - const raw = AlarmsType[alarmSelected - 1].time; - setRemindTime(normalizeTime(raw)) + } if (step < 5) { - setDirection(1); setStep((prev) => prev + 1); } else if (step === 5) { + const raw = AlarmsType[alarmSelected - 1].time; + setRemindTime(normalizeTime(raw)); + postSignData({ "email": "tesdfdfsst@gmail.com", "remindDefault": remindTime, diff --git a/apps/client/src/shared/apis/axios.ts b/apps/client/src/shared/apis/axios.ts index 13598ef8..db3c2d00 100644 --- a/apps/client/src/shared/apis/axios.ts +++ b/apps/client/src/shared/apis/axios.ts @@ -28,6 +28,6 @@ export interface postSignUpRequest { } export const postSignUp = async (data: postSignUpRequest) => { - const response = await apiRequest.post('/api/v1/auth/signup', {data}); + const response = await apiRequest.post('/api/v1/auth/signup', data); return response.data; }; \ No newline at end of file From 9ddf8104aca59f8cd795c6f617ef56b712e6608c Mon Sep 17 00:00:00 2001 From: jllee000 Date: Sat, 13 Sep 2025 15:31:09 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=EA=B5=AC=EC=A1=B0=EB=B6=84?= =?UTF-8?q?=ED=95=B4=20=ED=95=A0=EB=8B=B9=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/shared/apis/axios.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/client/src/shared/apis/axios.ts b/apps/client/src/shared/apis/axios.ts index db3c2d00..ebe439ec 100644 --- a/apps/client/src/shared/apis/axios.ts +++ b/apps/client/src/shared/apis/axios.ts @@ -27,7 +27,7 @@ export interface postSignUpRequest { fcmToken: string } -export const postSignUp = async (data: postSignUpRequest) => { - const response = await apiRequest.post('/api/v1/auth/signup', data); - return response.data; +export const postSignUp = async (responsedata: postSignUpRequest) => { + const {data} = await apiRequest.post('/api/v1/auth/signup', responsedata); + return data; }; \ No newline at end of file