Skip to content

Commit

Permalink
feat : patch study mandate
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper200207 committed Jul 5, 2024
1 parent 66ee116 commit 4618b6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/app/api/member.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
import { fetcher } from '@/app/api/fetcher';

const memberFetcher = fetcher();
Expand All @@ -10,4 +9,12 @@ const getSidebarInfo = (token: string, memberId: number) =>
},
});

export { getSidebarInfo };
const patchStudyMandate = (token: string, studyId: number, newStudyLeaderId: number) =>
memberFetcher(`/study/${studyId}/mandate/${newStudyLeaderId}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
},
});

export { getSidebarInfo, patchStudyMandate };
4 changes: 2 additions & 2 deletions src/hooks/useFetchWithToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export function useGetFetchWithToken(fetch: (token: string, ...props: any[]) =>
return result;
}

export function useMutateWithToken(fetch: (token: string, ...props: any[]) => Promise<FetchResult>) {
const user = useGetUser();
export function useMutateWithToken(fetch: (token: string, ...props: any[]) => Promise<FetchResult>, originUser?: any) {
const user = originUser !== undefined ? originUser : useGetUser();

return (...props: any[]) => fetch(user?.token || '', ...props);
}

0 comments on commit 4618b6d

Please sign in to comment.