feat(dashboard): collection product management (#7333)
* feat: implement collection management * fix: toasts * fix: use query keys from the lib --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import { queryClient } from "../../lib/medusa"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
CreateProductCollectionReq,
|
||||
UpdateProductCollectionProductsReq,
|
||||
UpdateProductCollectionReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
@@ -86,6 +87,29 @@ export const useUpdateCollection = (
|
||||
})
|
||||
}
|
||||
|
||||
export const useUpdateCollectionProducts = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
ProductCollectionRes,
|
||||
Error,
|
||||
UpdateProductCollectionProductsReq
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: UpdateProductCollectionProductsReq) =>
|
||||
client.collections.updateProducts(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: collectionsQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: collectionsQueryKeys.detail(id),
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useCreateCollection = (
|
||||
options?: UseMutationOptions<
|
||||
ProductCollectionRes,
|
||||
|
||||
Reference in New Issue
Block a user