Skip to content

Commit 4f08b8d

Browse files
authored
fix : 마이페이지 정보 수정 시 전역변수 user update (#129)
1 parent 41d24c7 commit 4f08b8d

3 files changed

Lines changed: 34 additions & 5 deletions

File tree

src/app/(auth)/(navigationsBarLayout)/mypage/tab/Mine.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ModifyForm } from '../ui/ModifyForm';
2222
import { useQueryClient } from '@tanstack/react-query';
2323
import { Badge } from '@/shared/ui/badge/Badge';
2424
import { toast } from 'sonner';
25+
import { useUserStore } from '@/entities/user/model/store';
2526

2627
export const Mine = () => {
2728
const queryClient = useQueryClient();
@@ -53,7 +54,7 @@ export const Mine = () => {
5354
const { mutateAsync: emailVerfiy } = useEmailVerify(BASE_URL || '');
5455
const { mutateAsync: modify } = useModifyInfo();
5556
const [languageList, setLanguageList] = useState<{ label: string; value: string }[]>([]);
56-
57+
const { setUser } = useUserStore();
5758
const myInfo = data?.data.result;
5859
const myRanking = ranking?.data.result;
5960

@@ -133,7 +134,9 @@ export const Mine = () => {
133134
request: body,
134135
image: editForm.profileImage ?? undefined,
135136
});
136-
137+
// setUser()
138+
console.log(response);
139+
setUser(response.result);
137140
toast.success(response.message, {
138141
richColors: false,
139142
style: {

src/entities/mypage/model/query.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ILanguages,
99
IModifyBody,
1010
IMyInfo,
11+
IUserInfoModifyResponse,
1112
Ranking,
1213
Report,
1314
SubmissionsResonse,
@@ -127,8 +128,7 @@ export const useModifyInfo = () => {
127128
request: IModifyBody; // 닉네임, 블로그, 깃허브 등 정보
128129
image?: File; // 프로필 이미지 (선택)
129130
}) => {
130-
console.log('image', image);
131-
console.log('request', request);
131+
132132
const formData = new FormData();
133133

134134
// request(JSON) 추가
@@ -139,7 +139,7 @@ export const useModifyInfo = () => {
139139
formData.append('image', image);
140140
}
141141

142-
const response = await ApiHelper.put(API_URL.MYPAGE.USER_INFO, formData, {
142+
const response = await ApiHelper.put<IUserInfoModifyResponse>(API_URL.MYPAGE.USER_INFO, formData, {
143143
headers: { 'Content-Type': 'multipart/form-data' },
144144
});
145145

src/entities/mypage/model/types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,29 @@ export type IModifyBody = {
104104
age: number;
105105
languageId: number | null;
106106
};
107+
108+
109+
110+
export interface IUserInfoModifyResponse {
111+
age: number;
112+
blogUrl: string;
113+
email: string;
114+
githubUrl: string;
115+
introduction: string;
116+
language: Language;
117+
nickname: string;
118+
profileImageUrl: string;
119+
tier: string;
120+
totalSolvedCount: number;
121+
userAuthTypes: string[]
122+
userRole: string;
123+
username: string;
124+
verified: boolean;
125+
}
126+
127+
export interface Language {
128+
id: number;
129+
judge0Id: number;
130+
name: string;
131+
version: string;
132+
}

0 commit comments

Comments
 (0)