This commit is contained in:
4
api/queries/wp/index.ts
Normal file
4
api/queries/wp/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './useGetProductAttributesDetail'
|
||||
export * from './useGetProductsDetail'
|
||||
export * from './useGetProductsList'
|
||||
export * from './useGetProductsVariationsList'
|
||||
10
api/queries/wp/useGetProductAttributesDetail.ts
Normal file
10
api/queries/wp/useGetProductAttributesDetail.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { unref } from 'vue'
|
||||
import { getProductAttributesDetail } from '~/api/endpoints/wp'
|
||||
|
||||
export const useGetProductAttributesDetail = (productId: MaybeRef<number>) => {
|
||||
return useQuery({
|
||||
queryKey: ['get-products-detail', productId],
|
||||
queryFn: () => getProductAttributesDetail(unref(productId)),
|
||||
})
|
||||
}
|
||||
11
api/queries/wp/useGetProductsDetail.ts
Normal file
11
api/queries/wp/useGetProductsDetail.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { unref } from 'vue'
|
||||
import { getProductsDetail } from '~/api/endpoints/wp'
|
||||
|
||||
export const useGetProductsDetail = (productId: MaybeRef<number>) => {
|
||||
return useQuery({
|
||||
queryKey: ['get-products-detail', productId],
|
||||
queryFn: () => getProductsDetail(unref(productId)),
|
||||
enabled: !!unref(productId),
|
||||
})
|
||||
}
|
||||
10
api/queries/wp/useGetProductsList.ts
Normal file
10
api/queries/wp/useGetProductsList.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { getProductsList } from '~/api/endpoints/wp/getProductsList'
|
||||
|
||||
export const useGetProductsList = () => {
|
||||
return useQuery({
|
||||
queryKey: ['get-products-list'],
|
||||
queryFn: () => getProductsList(),
|
||||
staleTime: Infinity,
|
||||
})
|
||||
}
|
||||
11
api/queries/wp/useGetProductsVariationsList.ts
Normal file
11
api/queries/wp/useGetProductsVariationsList.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { unref } from 'vue'
|
||||
import { getProductsVariationsList } from '~/api/endpoints/wp'
|
||||
|
||||
export const useGetProductsVariationsList = (productId: MaybeRef<number>) => {
|
||||
return useQuery({
|
||||
queryKey: ['get-products-variations-list', productId],
|
||||
queryFn: () => getProductsVariationsList(unref(productId)),
|
||||
enabled: !!unref(productId),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user