Skip to content

Commit d667d37

Browse files
authored
Merge pull request #160 from team-ppointer/feat/native/menu,scrap-#159
Feat/native/menu,scrap #159
2 parents 66dd25f + b4b5d7b commit d667d37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2983
-737
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { client } from '@/apis/client';
2+
import { paths } from '@/types/api/schema';
23

3-
const deleteAccount = async () => {
4-
return await client.DELETE('/api/student/auth/quit');
4+
type QuitRequest =
5+
paths['/api/student/auth/quit']['post']['requestBody']['content']['application/json'];
6+
7+
const deleteAccount = async (request: QuitRequest) => {
8+
return await client.POST('/api/student/auth/quit', {
9+
body: request,
10+
});
511
};
612

713
export default deleteAccount;
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { client } from '@/apis/client';
2+
import { paths } from '@/types/api/schema';
23

3-
const deleteAccount = async () => {
4-
return await client.DELETE('/api/student/auth/quit');
4+
type QuitRequest =
5+
paths['/api/student/auth/quit']['post']['requestBody']['content']['application/json'];
6+
7+
const deleteAccount = async (request: QuitRequest) => {
8+
return await client.POST('/api/student/auth/quit', {
9+
body: request,
10+
});
511
};
612

713
export default deleteAccount;
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
import postAllowPush from './postAllowPush';
21
import postChangePassword from './postChangePassword';
32
import postPushToken from './postPushToken';
3+
import usePutAllowPush from './putAllowPush';
44
import putMe from './putMe';
55
import useGetMe from './useGetMe';
6+
import useGetPushSetting from './useGetPushSetting';
7+
import usePostFeedback from './postFeeback';
68

7-
export { postAllowPush, postChangePassword, postPushToken, putMe, useGetMe };
9+
export {
10+
usePutAllowPush,
11+
postChangePassword,
12+
postPushToken,
13+
putMe,
14+
useGetMe,
15+
useGetPushSetting,
16+
usePostFeedback,
17+
};

apps/native/src/apis/controller/student/me/postAllowPush.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { client, TanstackQueryClient } from '@/apis/client';
2+
import { components } from '@/types/api/schema';
3+
import { useMutation } from '@tanstack/react-query';
4+
5+
type FeedbackCreateRequest = components['schemas']['FeedbackDTO.Request'];
6+
7+
const usePostFeedback = () => {
8+
return useMutation({
9+
mutationFn: async (data: FeedbackCreateRequest) => {
10+
const response = await client.POST('/api/student/feedback', {
11+
body: data,
12+
});
13+
return response.data;
14+
},
15+
});
16+
};
17+
18+
export default usePostFeedback;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useMutation, useQueryClient } from '@tanstack/react-query';
2+
import { client, TanstackQueryClient } from '@/apis/client';
3+
import { components } from '@schema';
4+
5+
type UpdatePushSettingsRequest = components['schemas']['StudentPushDTO.UpdateSettingsRequest'];
6+
7+
const usePutAllowPush = () => {
8+
const queryClient = useQueryClient();
9+
10+
return useMutation({
11+
mutationFn: async (data: UpdatePushSettingsRequest) => {
12+
const response = await client.PUT('/api/student/me/push/settings', {
13+
body: data,
14+
});
15+
return response.data;
16+
},
17+
onSuccess: (data) => {
18+
void queryClient.invalidateQueries({
19+
queryKey: TanstackQueryClient.queryOptions('get', '/api/student/me/push/settings').queryKey,
20+
});
21+
},
22+
});
23+
};
24+
25+
export default usePutAllowPush;
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
import { client } from '@/apis/client';
1+
import { client, TanstackQueryClient } from '@/apis/client';
22
import { components } from '@schema';
3+
import { useMutation, useQueryClient } from '@tanstack/react-query';
34

45
type StudentUpdateRequest = components['schemas']['StudentUpdateRequest'];
56

6-
const putMe = async (data: StudentUpdateRequest) => {
7-
try {
8-
const response = await client.PUT('/api/student/me', {
9-
body: data,
10-
});
11-
return { isSuccess: true, data: response.data };
12-
} catch (error) {
13-
return { isSuccess: false, error: error };
14-
}
7+
const usePutMe = () => {
8+
const queryClient = useQueryClient();
9+
return useMutation({
10+
mutationFn: async (data: StudentUpdateRequest) => {
11+
const response = await client.PUT('/api/student/me', {
12+
body: data,
13+
});
14+
return response.data;
15+
},
16+
onSuccess: (data) => {
17+
void queryClient.invalidateQueries({
18+
queryKey: TanstackQueryClient.queryOptions('get', '/api/student/me').queryKey,
19+
});
20+
},
21+
});
1522
};
1623

17-
export default putMe;
24+
export default usePutMe;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { TanstackQueryClient } from '@/apis/client';
2+
3+
type Props = {
4+
enabled?: boolean;
5+
};
6+
7+
const useGetPushSetting = ({ enabled = true }: Props) => {
8+
return TanstackQueryClient.useQuery('get', '/api/student/me/push/settings', {
9+
enabled,
10+
});
11+
};
12+
13+
export default useGetPushSetting;

apps/native/src/apis/controller/student/qna/useGetQnaFiles.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import { TanstackQueryClient } from '@/apis/client';
2+
import { paths } from '@/types/api/schema';
23

3-
type Props = {
4-
enabled?: boolean;
5-
};
4+
type GetQnaFilesParams = paths['/api/student/qna/files']['get']['parameters']['query'];
65

7-
const useGetQnaFiles = ({ enabled = true }: Props = {}) => {
6+
const useGetQnaFiles = (params: GetQnaFilesParams = {}, enabled = true) => {
87
return TanstackQueryClient.useQuery(
98
'get',
109
'/api/student/qna/files',
11-
{},
10+
{
11+
params: {
12+
query: params,
13+
},
14+
},
1215
{ enabled }
1316
);
1417
};
1518

1619
export default useGetQnaFiles;
17-
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { TanstackQueryClient } from '@/apis/client';
2+
import { paths } from '@/types/api/schema';
23

3-
type Props = {
4-
query: string;
5-
enabled?: boolean;
6-
};
4+
type SchoolParams = paths['/api/student/school']['get']['parameters']['query'];
75

8-
const useGetSchool = ({ query, enabled = true }: Props) => {
9-
return TanstackQueryClient.useQuery('get', '/api/student/school', {
10-
query: {
11-
query,
6+
const useGetSchool = (params: SchoolParams = {}, enabled = true) => {
7+
return TanstackQueryClient.useQuery(
8+
'get',
9+
'/api/student/school',
10+
{
11+
params: {
12+
query: params,
13+
},
1214
},
13-
enabled: enabled && query.trim().length > 0,
14-
});
15+
{
16+
enabled,
17+
}
18+
);
1519
};
1620

1721
export default useGetSchool;

0 commit comments

Comments
 (0)