Skip to content

Commit

Permalink
fix(medusa-react): invalidate products query on category delete (#3485)
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan authored Mar 15, 2023
1 parent 77d4622 commit 4ede919
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-vans-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa-react": patch
---

fix(medusa-react): invalidate products query on category delete
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ export const useAdminUpdateProductCategory = (
return useMutation(
(payload: AdminPostProductCategoriesCategoryReq) =>
client.admin.productCategories.update(id, payload),
buildOptions(
queryClient,
[
adminProductCategoryKeys.lists(),
adminProductCategoryKeys.detail(id),
adminProductKeys.details(),
],
options
buildOptions(
queryClient,
[
adminProductCategoryKeys.lists(),
adminProductCategoryKeys.detail(id),
adminProductKeys.details(),
],
options
)
)
)
}

/**
Expand All @@ -95,11 +95,16 @@ export const useAdminDeleteProductCategory = (
) => {
const { client } = useMedusa()
const queryClient = useQueryClient()

return useMutation(
() => client.admin.productCategories.delete(id),
buildOptions(
queryClient,
[adminProductCategoryKeys.lists(), adminProductCategoryKeys.detail(id)],
[
adminProductCategoryKeys.lists(),
adminProductCategoryKeys.detail(id),
adminProductKeys.all
],
options
)
)
Expand Down

0 comments on commit 4ede919

Please sign in to comment.