-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.ts
More file actions
106 lines (83 loc) · 2.19 KB
/
user.ts
File metadata and controls
106 lines (83 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import apiInstance from '@/api/apiInstance';
import { API_BASE_URL } from '@/api/config.ts';
import { ServerResponse } from '@/api/types';
export const kakaoOauth2LoginUrl = `${API_BASE_URL}/oauth2/authorization/kakao`;
type ProfileCommonArgs = {
memberName: string;
memberExplain: string;
};
type ProfileMutationArgs = ProfileCommonArgs & {
image: File | null;
};
export type ProfileQueryResp = ProfileCommonArgs & {
imageUrl: string;
uuid: string;
};
export const createProfile = async ({
memberName,
memberExplain,
image,
}: ProfileMutationArgs) => {
const res = await apiInstance.post('v1/members', {
memberName,
memberExplain,
image,
});
return res.data;
};
export const changeProfile = async ({
memberName,
memberExplain,
image,
}: ProfileMutationArgs) => {
const formData = new FormData();
formData.append('memberName', memberName);
formData.append('memberExplain', memberExplain);
if (image) {
formData.append('image', image);
}
const res = await apiInstance.put('v1/members', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
return res.data;
};
export const getMyProfile = async (): Promise<ProfileQueryResp> => {
const res = await apiInstance.get<ServerResponse<ProfileQueryResp>>(
'v1/members/own-profile'
);
return res.data.data;
};
export const getProfile = async (uuid: string): Promise<ProfileQueryResp> => {
const res = await apiInstance.get<ServerResponse<ProfileQueryResp>>(
`v1/members/profile/${uuid}`
);
return res.data.data;
};
export const logout = async () => {
const res = await apiInstance.post(`v1/logout`);
return res.data;
};
type TeamAbsInfo = {
teamId: number;
teamName: string;
teamImageUrl: string;
};
type MemberInfoResp = {
memberName: string;
memberImageUrl: string;
teamAbstractResponses: TeamAbsInfo[];
};
export const getMemberInfo = async () => {
// if (isDevMode()) {
// return membersInfoMock.data;
// }
const res =
await apiInstance.get<ServerResponse<MemberInfoResp>>('v1/members/info');
return res.data.data;
};
export const withdrawMember = async () => {
const res = await apiInstance.delete('v1/members');
return res.data;
};