Skip to content

Commit

Permalink
feat: 수업 리스트 편집 API (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
newminkyung committed Feb 1, 2023
1 parent df23cc1 commit 3a04189
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/pages/Class/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { AxiosResponse } from 'axios';

import { api } from '@/api';

const API_URL = `/class/`;
const API_URL = `/class`;

const getClassList = (): Promise<AxiosResponse<ClassListResponse>> => {
return api.get(`/users${API_URL}`);
return api.get(`/users${API_URL}/`);
};

export { getClassList };
const editClassList = (payload: ClassListIdRequest) => {
return api.patch(`/users${API_URL}/`, payload);
};

export { getClassList, editClassList };
1 change: 1 addition & 0 deletions src/pages/Class/hooks/query/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './useClassListQuery';
export * from './useEditClassListMutation';
12 changes: 12 additions & 0 deletions src/pages/Class/hooks/query/useEditClassListMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useMutation, UseMutationOptions } from 'react-query';
import { AxiosError, AxiosResponse } from 'axios';

import { editClassList } from '../../api';

export const useEditClassListMutation = (
options?: UseMutationOptions<AxiosResponse, AxiosError, ClassListIdRequest>
) => {
return useMutation((payload) => editClassList(payload), {
...options,
});
};
4 changes: 4 additions & 0 deletions src/types/class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ type ClassListResponse = {
privilege: PrivilegeNumber;
is_show: boolean;
}[];

type ClassListIdRequest = {
class_id: number;
}[];

0 comments on commit 3a04189

Please sign in to comment.