-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathuseUpdateStudyset.tsx
More file actions
28 lines (26 loc) · 949 Bytes
/
useUpdateStudyset.tsx
File metadata and controls
28 lines (26 loc) · 949 Bytes
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
import { AxiosError, AxiosResponse } from 'axios';
import { useMutation, useQueryClient } from 'react-query';
import { StudysetRequest, StudysetReturn } from 'neurostore-typescript-sdk';
import API from 'utils/api';
import { useSnackbar } from 'notistack';
const useUpdateStudyset = () => {
const queryClient = useQueryClient();
const { enqueueSnackbar } = useSnackbar();
return useMutation<
AxiosResponse<StudysetReturn>,
AxiosError,
{
studysetId: string;
studyset: StudysetRequest;
},
unknown
>((args) => API.NeurostoreServices.StudySetsService.studysetsIdPut(args.studysetId, args.studyset), {
onSuccess: () => {
queryClient.invalidateQueries('studysets');
},
onError: () => {
enqueueSnackbar('there was an error updating the studyset', { variant: 'error' });
},
});
};
export default useUpdateStudyset;