Skip to content

Commit f9e8ba6

Browse files
authored
fix: update mutation function to use CollectionRequest type and enhance collection properties (#3052)
1 parent 69e3ce2 commit f9e8ba6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

frontend/src/modules/admin/modules/collections/pages/collection.page.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ const onEditCollection = (collectionId: string) => {
215215
};
216216
217217
const updateMutation = useMutation({
218-
mutationFn: ({ id, collection }: { id: string; collection: CollectionModel }) => COLLECTIONS_SERVICE.update(id, collection as CollectionRequest),
218+
mutationFn: ({ id, collection }: { id: string; collection: CollectionRequest }) => COLLECTIONS_SERVICE.update(id, collection),
219219
onMutate: () => {
220220
Message.info(null, {
221221
title: 'Collection is being featured',
222222
});
223223
},
224-
onSuccess: (collection: CollectionModel) => {
224+
onSuccess: (collection: CollectionRequest) => {
225225
Message.closeAll();
226226
Message.success(`Collection successfully ${collection!.starred ? 'mark as featured' : 'unmark as featured'}`);
227227
queryClient.invalidateQueries({
@@ -244,7 +244,14 @@ const ontoggleStar = (collectionId: string) => {
244244
updateMutation.mutate({
245245
id: collectionId,
246246
collection: {
247-
...collection,
247+
categoryId: collection.categoryId || null,
248+
description: collection.description,
249+
name: collection.name,
250+
projects: collection.projects.map((project) => ({
251+
id: project.id,
252+
starred: project.starred,
253+
})),
254+
slug: collection.slug,
248255
starred: !collection.starred,
249256
},
250257
});
@@ -291,7 +298,6 @@ const closeRemoveDialog = () => {
291298
removeCollection.value = false;
292299
removeCollectionId.value = '';
293300
};
294-
295301
</script>
296302

297303
<script lang="ts">

0 commit comments

Comments
 (0)