From e1d494156bd716cbfe9f2902f0c92ce7c168bb9e Mon Sep 17 00:00:00 2001 From: hanseo Date: Mon, 13 Jan 2025 02:29:06 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20friendProfile=20get=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=ED=95=A8=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/handlers.ts | 4 +++- src/mocks/home/resolvers/friendModalResover.ts | 13 +++++++++++++ .../home/responses/friendModalResponses.ts | 13 +++++++++++++ src/shared/apisV2/home/axios/index.ts | 6 ++++++ src/shared/apisV2/home/queries/index.ts | 18 ++++++++++++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/mocks/home/resolvers/friendModalResover.ts create mode 100644 src/mocks/home/responses/friendModalResponses.ts diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index 23987bbd..17c2b13e 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -1,3 +1,5 @@ +import { friendResolvers } from '@/mocks/home/resolvers/friendModalResover'; + import { homeResolvers } from './home/resolvers/homeResolvers'; -export const handlers = [...homeResolvers]; +export const handlers = [...homeResolvers, ...friendResolvers]; diff --git a/src/mocks/home/resolvers/friendModalResover.ts b/src/mocks/home/resolvers/friendModalResover.ts new file mode 100644 index 00000000..7b23b704 --- /dev/null +++ b/src/mocks/home/resolvers/friendModalResover.ts @@ -0,0 +1,13 @@ +import { HttpResponse, http } from 'msw'; + +import { FRIEND_MODAL_RES } from '@/mocks/home/responses/friendModalResponses'; + +export const FRIEND_MODAL_URL = { + GET_PROFILE_INFO: 'api/v2/profiles', +}; + +export const friendResolvers = [ + http.get(FRIEND_MODAL_URL.GET_PROFILE_INFO, async () => { + return HttpResponse.json(FRIEND_MODAL_RES.GET_PROFILE_INFO); + }), +]; diff --git a/src/mocks/home/responses/friendModalResponses.ts b/src/mocks/home/responses/friendModalResponses.ts new file mode 100644 index 00000000..cbb50c0f --- /dev/null +++ b/src/mocks/home/responses/friendModalResponses.ts @@ -0,0 +1,13 @@ +export const FRIEND_MODAL_RES = { + GET_PROFILE_INFO: { + status: 200, + message: '요청이 성공했습니다.', + data: { + id: '3', + name: '유영재', + email: 'yjzzangman@gmail.com', + imageUrl: '{profile image Url}', + isPushEnabled: true, + }, + }, +}; diff --git a/src/shared/apisV2/home/axios/index.ts b/src/shared/apisV2/home/axios/index.ts index 21f66d50..5972fc8e 100644 --- a/src/shared/apisV2/home/axios/index.ts +++ b/src/shared/apisV2/home/axios/index.ts @@ -1,5 +1,6 @@ import axios from 'axios'; +import { FRIEND_MODAL_URL } from '@/mocks/home/resolvers/friendModalResover'; import { HOME_MOCK_URL } from '@/mocks/home/resolvers/homeResolvers'; export const getCategoryTask = async (startDate: string, endDate: string) => { @@ -8,3 +9,8 @@ export const getCategoryTask = async (startDate: string, endDate: string) => { }); return data; }; + +export const getFriendProfile = async () => { + const { data } = await axios.get(FRIEND_MODAL_URL.GET_PROFILE_INFO); + return data; +}; diff --git a/src/shared/apisV2/home/queries/index.ts b/src/shared/apisV2/home/queries/index.ts index e69de29b..618ad6ab 100644 --- a/src/shared/apisV2/home/queries/index.ts +++ b/src/shared/apisV2/home/queries/index.ts @@ -0,0 +1,18 @@ +import { useQuery } from '@tanstack/react-query'; + +import { getFriendProfile } from '@/shared/apisV2/home/axios'; + +interface FriendProfileData { + id: number; + name: string; + email: string; + imageUrl: string; + isPushEnabled: boolean; +} + +export const useGetFriendProfile = () => { + return useQuery({ + queryKey: ['FriendProfile'], + queryFn: () => getFriendProfile(), + }); +}; From 79268439c70661452700626116435fa9263e8176 Mon Sep 17 00:00:00 2001 From: hanseo Date: Mon, 13 Jan 2025 03:49:07 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20msw=20=EC=84=A4=EC=A0=95=EB=B7=B0?= =?UTF-8?q?=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/handlers.ts | 4 ++-- .../home/resolvers/friendModalResover.ts | 13 ----------- .../modal/resolvers/settingModalResover.ts | 13 +++++++++++ .../responses/settingModalResponses.ts} | 2 +- src/shared/apisV2/home/axios/index.ts | 6 ----- src/shared/apisV2/home/queries/index.ts | 18 --------------- src/shared/apisV2/modal/axios/index.ts | 8 +++++++ src/shared/apisV2/modal/queries/index.ts | 18 +++++++++++++++ .../AccountContent/AccountContent.tsx | 3 +++ .../ModalContentsSetting.tsx | 23 +++++++++++++++---- 10 files changed, 64 insertions(+), 44 deletions(-) delete mode 100644 src/mocks/home/resolvers/friendModalResover.ts create mode 100644 src/mocks/modal/resolvers/settingModalResover.ts rename src/mocks/{home/responses/friendModalResponses.ts => modal/responses/settingModalResponses.ts} (86%) create mode 100644 src/shared/apisV2/modal/axios/index.ts create mode 100644 src/shared/apisV2/modal/queries/index.ts diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index 17c2b13e..781de75b 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -1,5 +1,5 @@ -import { friendResolvers } from '@/mocks/home/resolvers/friendModalResover'; +import { userProfileResolvers } from '@/mocks/modal/resolvers/settingModalResover'; import { homeResolvers } from './home/resolvers/homeResolvers'; -export const handlers = [...homeResolvers, ...friendResolvers]; +export const handlers = [...homeResolvers, ...userProfileResolvers]; diff --git a/src/mocks/home/resolvers/friendModalResover.ts b/src/mocks/home/resolvers/friendModalResover.ts deleted file mode 100644 index 7b23b704..00000000 --- a/src/mocks/home/resolvers/friendModalResover.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { HttpResponse, http } from 'msw'; - -import { FRIEND_MODAL_RES } from '@/mocks/home/responses/friendModalResponses'; - -export const FRIEND_MODAL_URL = { - GET_PROFILE_INFO: 'api/v2/profiles', -}; - -export const friendResolvers = [ - http.get(FRIEND_MODAL_URL.GET_PROFILE_INFO, async () => { - return HttpResponse.json(FRIEND_MODAL_RES.GET_PROFILE_INFO); - }), -]; diff --git a/src/mocks/modal/resolvers/settingModalResover.ts b/src/mocks/modal/resolvers/settingModalResover.ts new file mode 100644 index 00000000..ee754118 --- /dev/null +++ b/src/mocks/modal/resolvers/settingModalResover.ts @@ -0,0 +1,13 @@ +import { HttpResponse, http } from 'msw'; + +import { SETTING_MODAL_RES } from '@/mocks/modal/responses/settingModalResponses'; + +export const SETTING_MODAL_URL = { + GET_PROFILE_INFO: 'api/v2/profiles', +}; + +export const userProfileResolvers = [ + http.get(SETTING_MODAL_URL.GET_PROFILE_INFO, async () => { + return HttpResponse.json(SETTING_MODAL_RES.GET_PROFILE_INFO); + }), +]; diff --git a/src/mocks/home/responses/friendModalResponses.ts b/src/mocks/modal/responses/settingModalResponses.ts similarity index 86% rename from src/mocks/home/responses/friendModalResponses.ts rename to src/mocks/modal/responses/settingModalResponses.ts index cbb50c0f..5aba39c0 100644 --- a/src/mocks/home/responses/friendModalResponses.ts +++ b/src/mocks/modal/responses/settingModalResponses.ts @@ -1,4 +1,4 @@ -export const FRIEND_MODAL_RES = { +export const SETTING_MODAL_RES = { GET_PROFILE_INFO: { status: 200, message: '요청이 성공했습니다.', diff --git a/src/shared/apisV2/home/axios/index.ts b/src/shared/apisV2/home/axios/index.ts index 5972fc8e..21f66d50 100644 --- a/src/shared/apisV2/home/axios/index.ts +++ b/src/shared/apisV2/home/axios/index.ts @@ -1,6 +1,5 @@ import axios from 'axios'; -import { FRIEND_MODAL_URL } from '@/mocks/home/resolvers/friendModalResover'; import { HOME_MOCK_URL } from '@/mocks/home/resolvers/homeResolvers'; export const getCategoryTask = async (startDate: string, endDate: string) => { @@ -9,8 +8,3 @@ export const getCategoryTask = async (startDate: string, endDate: string) => { }); return data; }; - -export const getFriendProfile = async () => { - const { data } = await axios.get(FRIEND_MODAL_URL.GET_PROFILE_INFO); - return data; -}; diff --git a/src/shared/apisV2/home/queries/index.ts b/src/shared/apisV2/home/queries/index.ts index 618ad6ab..e69de29b 100644 --- a/src/shared/apisV2/home/queries/index.ts +++ b/src/shared/apisV2/home/queries/index.ts @@ -1,18 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; - -import { getFriendProfile } from '@/shared/apisV2/home/axios'; - -interface FriendProfileData { - id: number; - name: string; - email: string; - imageUrl: string; - isPushEnabled: boolean; -} - -export const useGetFriendProfile = () => { - return useQuery({ - queryKey: ['FriendProfile'], - queryFn: () => getFriendProfile(), - }); -}; diff --git a/src/shared/apisV2/modal/axios/index.ts b/src/shared/apisV2/modal/axios/index.ts new file mode 100644 index 00000000..c4daa212 --- /dev/null +++ b/src/shared/apisV2/modal/axios/index.ts @@ -0,0 +1,8 @@ +import axios from 'axios'; + +import { SETTING_MODAL_URL } from '@/mocks/modal/resolvers/settingModalResover'; + +export const getUserProfile = async () => { + const { data } = await axios.get(SETTING_MODAL_URL.GET_PROFILE_INFO); + return data; +}; diff --git a/src/shared/apisV2/modal/queries/index.ts b/src/shared/apisV2/modal/queries/index.ts new file mode 100644 index 00000000..b69e6dc3 --- /dev/null +++ b/src/shared/apisV2/modal/queries/index.ts @@ -0,0 +1,18 @@ +import { useSuspenseQuery } from '@tanstack/react-query'; + +import { getUserProfile } from '@/shared/apisV2/modal/axios'; + +export interface UserProfile { + id: string; + name: string; + email: string; + imageUrl: string; + isPushEnabled: boolean; +} + +export const useGetUserProfile = () => { + return useSuspenseQuery({ + queryKey: ['UserProfile'], + queryFn: () => getUserProfile(), + }); +}; diff --git a/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx b/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx index be24104a..cf2adb24 100644 --- a/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx +++ b/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx @@ -8,8 +8,11 @@ import MailIcon from '@/shared/assets/svgs/mail.svg?react'; import ButtonSettingSaved from '../ButtonSettingSaved/ButtonSettingSaved'; interface User { + id: string; name: string; email: string; + imageUrl: string; + isPushEnabled: boolean; } interface AccountContentProps { diff --git a/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx b/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx index 816fad9c..3b1a22ef 100644 --- a/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx +++ b/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx @@ -3,17 +3,32 @@ import { useState } from 'react'; import SettingIcon from '@/shared/assets/svgs/setting.svg?react'; import UserIcon from '@/shared/assets/svgs/user_circle.svg?react'; +import { useGetUserProfile } from '@/shared/apisV2/modal/queries'; + import AccountContent from './AccountContent/AccountContent'; import Tabs from './Tabs/Tabs'; import WorkSpaceSettingContent from './WorkspaceSettingContent/WorkspaceSettingContent'; const ModalContentsSetting = () => { const [activeTab, setActiveTab] = useState('account'); - const user = { - name: '홍길동', - email: 'honggildong@example.com', + const { data, isLoading, error } = useGetUserProfile(); + + if (isLoading) { + return
Loading...
; + } + if (error) { + return
Error loading user profile
; + } + + const userProfiles = { + id: data?.id, + name: data?.name, + email: data?.email, + imageUrl: data?.imageUrl, + isPushEnabled: data?.isPushEnabled, }; + console.log('user', userProfiles); const personalWorkspaces = ['개인 프로젝트']; const teamWorkspaces = ['팀 A 프로젝트', '팀 B 프로젝트']; @@ -42,7 +57,7 @@ const ModalContentsSetting = () => {
{activeTab === 'account' ? ( - + ) : ( )} From eb48d117d96c0bcfa6e13fb6ac4bdf584bfabd30 Mon Sep 17 00:00:00 2001 From: hanseo Date: Mon, 13 Jan 2025 03:49:27 +0900 Subject: [PATCH 3/5] =?UTF-8?q?remove:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C=20(#245)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx b/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx index 3b1a22ef..5add34c9 100644 --- a/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx +++ b/src/shared/layout/Sidebar/ModalContentsSetting/ModalContentsSetting.tsx @@ -28,7 +28,6 @@ const ModalContentsSetting = () => { isPushEnabled: data?.isPushEnabled, }; - console.log('user', userProfiles); const personalWorkspaces = ['개인 프로젝트']; const teamWorkspaces = ['팀 A 프로젝트', '팀 B 프로젝트']; From f80d4a490e8682b56e9c28ad3049e2d25b747567 Mon Sep 17 00:00:00 2001 From: hanseo Date: Mon, 13 Jan 2025 13:00:53 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=EC=84=A4=EC=A0=95=EB=B7=B0=20msw?= =?UTF-8?q?=20get=EA=B9=8C=EC=A7=80=20=EC=97=B0=EA=B2=B0=20(#245)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/modal/responses/settingModalResponses.ts | 7 +++++++ src/shared/apisV2/modal/queries/index.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mocks/modal/responses/settingModalResponses.ts b/src/mocks/modal/responses/settingModalResponses.ts index 5aba39c0..62c07315 100644 --- a/src/mocks/modal/responses/settingModalResponses.ts +++ b/src/mocks/modal/responses/settingModalResponses.ts @@ -11,3 +11,10 @@ export const SETTING_MODAL_RES = { }, }, }; + +export const SETTING_MODIFY_RES = { + PUT_PROFILE: { + status: 200, + message: '요청이 성공했습니다.', + }, +}; diff --git a/src/shared/apisV2/modal/queries/index.ts b/src/shared/apisV2/modal/queries/index.ts index b69e6dc3..f1a1ccb7 100644 --- a/src/shared/apisV2/modal/queries/index.ts +++ b/src/shared/apisV2/modal/queries/index.ts @@ -1,4 +1,4 @@ -import { useSuspenseQuery } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; import { getUserProfile } from '@/shared/apisV2/modal/axios'; @@ -11,7 +11,7 @@ export interface UserProfile { } export const useGetUserProfile = () => { - return useSuspenseQuery({ + return useQuery({ queryKey: ['UserProfile'], queryFn: () => getUserProfile(), }); From 8af1e868a38c6113addbe8bb44115a2f9e96f62e Mon Sep 17 00:00:00 2001 From: hanseo Date: Mon, 13 Jan 2025 13:05:59 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountContent/AccountContent.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx b/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx index cf2adb24..ad4b0289 100644 --- a/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx +++ b/src/shared/layout/Sidebar/ModalContentsSetting/AccountContent/AccountContent.tsx @@ -8,11 +8,11 @@ import MailIcon from '@/shared/assets/svgs/mail.svg?react'; import ButtonSettingSaved from '../ButtonSettingSaved/ButtonSettingSaved'; interface User { - id: string; - name: string; - email: string; - imageUrl: string; - isPushEnabled: boolean; + id: string | undefined; + name: string | undefined; + email: string | undefined; + imageUrl: string | undefined; + isPushEnabled: boolean | undefined; } interface AccountContentProps {