Skip to content

Commit

Permalink
fix collection update
Browse files Browse the repository at this point in the history
  • Loading branch information
olexh committed May 5, 2024
1 parent b628a00 commit 36d336a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 4 additions & 3 deletions services/api/collections/updateCollection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
BaseFetchRequestProps,
FetchRequestProps,
fetchRequest,
} from '@/services/api/fetchRequest';

Expand Down Expand Up @@ -28,10 +27,12 @@ export default async function req({
params,
...props
}: BaseFetchRequestProps<Params>): Promise<Response> {
const { reference, ...restParams } = params!;

return fetchRequest<Response>({
...props,
path: `/collections/${params?.reference}`,
path: `/collections/${reference}`,
method: 'put',
params: params,
params: restParams,
});
}
10 changes: 2 additions & 8 deletions services/hooks/collections/useUpdateCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { Params as CollectionRequest } from '@/services/api/collections/createCollection';
import updateCollection from '@/services/api/collections/updateCollection';

const useUpdateCollection = ({
reference,
...params
}: {
const useUpdateCollection = (params: {
reference: string;
} & CollectionRequest) => {
const queryClient = useQueryClient();
Expand All @@ -20,10 +17,7 @@ const useUpdateCollection = ({
return useMutation({
mutationFn: () =>
updateCollection({
params: {
...params,
reference: reference,
},
params,
}),
mutationKey: ['updateCollection'],
onSuccess: async (data) => {
Expand Down

0 comments on commit 36d336a

Please sign in to comment.