создаю телегу товаров
All checks were successful
Deploy / build (push) Successful in 45s

This commit is contained in:
alsaze
2025-10-03 19:26:39 +03:00
parent bb195777c3
commit 7a7d27c7ae
18 changed files with 87 additions and 8 deletions

4
api/queries/wp/index.ts Normal file
View File

@@ -0,0 +1,4 @@
export * from './useGetProductAttributesDetail'
export * from './useGetProductsDetail'
export * from './useGetProductsList'
export * from './useGetProductsVariationsList'

View 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)),
})
}

View 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),
})
}

View 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,
})
}

View 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),
})
}