product-card
Some checks failed
Deploy / build-and-deploy (push) Failing after 9s

This commit is contained in:
Veselov
2025-09-21 01:27:48 +03:00
parent e2ebf54d56
commit 9b42223a97
10 changed files with 99 additions and 4 deletions

View File

@@ -0,0 +1 @@
export * from './postOrdersCreate'

View File

@@ -0,0 +1,4 @@
import api from '~/api/instance'
export const postOrdersCreate = async (parent_id: number | undefined) =>
await api.wc.v3OrdersCreate({ parent_id })

1
api/mutations/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './usePostOrdersCreate'

View File

@@ -0,0 +1,19 @@
import type { MaybeRef } from 'vue'
import { useMutation, useQueryClient } from '@tanstack/vue-query'
import { unref } from 'vue'
import { postOrdersCreate } from '~/api/endpoints/orders'
export const usePostOrdersCreate = () => {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (params: { parent_id: MaybeRef<number | undefined> }) =>
postOrdersCreate(unref(params.parent_id)),
onSuccess: (data, variables) => {
queryClient.invalidateQueries({
queryKey: ['post-orders-create', unref(variables.parent_id)],
})
},
})
}