Skip to content

Commit

Permalink
Switch share settings update to use PUT request
Browse files Browse the repository at this point in the history
  • Loading branch information
kahkeng committed Jul 12, 2023
1 parent 17b5b45 commit 18bb4e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/api/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useMutation, useQueryClient } from 'react-query';
import { postCloneSession, postUpdateShareSettings } from '@/api/posts';
import { postCloneSession } from '@/api/posts';
import { putShareSettings } from '@/api/puts';

export const useMutationUpdateShareSettings = (sessionId: string) => {
const mutationFn = ({ metadata }: { metadata: any }) => {
return postUpdateShareSettings(sessionId, metadata);
return putShareSettings(sessionId, metadata);
};

const queryClient = useQueryClient();
Expand Down
11 changes: 0 additions & 11 deletions src/api/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ import { getBackendApiUrl } from '@/utils/backend';

const headers = { Accept: 'application/json' };

export const postUpdateShareSettings = (sessionId: string, metadata: any = {}) => {
const backendUrl = getBackendApiUrl();
return axios
.post(`${backendUrl}/api/share_settings/${sessionId}`, metadata, {
withCredentials: true,
headers,
})
.then((res) => res.data)
.catch((err) => console.log(err));
};

export const postCloneSession = (sessionId: string, metadata: any = {}) => {
const backendUrl = getBackendApiUrl();
return axios
Expand Down
15 changes: 15 additions & 0 deletions src/api/puts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';
import { getBackendApiUrl } from '@/utils/backend';

const headers = { Accept: 'application/json' };

export const putShareSettings = (sessionId: string, metadata: any = {}) => {
const backendUrl = getBackendApiUrl();
return axios
.put(`${backendUrl}/api/share_settings/${sessionId}`, metadata, {
withCredentials: true,
headers,
})
.then((res) => res.data)
.catch((err) => console.log(err));
};

0 comments on commit 18bb4e9

Please sign in to comment.