paxton-front/composables/useProductsList.ts
alsaze d038b66c94
All checks were successful
Deploy / build (push) Successful in 51s
создаю телегу товаров
2025-10-10 01:42:07 +03:00

27 lines
943 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { computed } from 'vue'
import { useGetProductsList } from '~/api/queries/wp'
import { useProduct } from '~/composables'
export const useProductsList = () => {
const { getAttribute } = useProduct()
// TODO перенести запрос на сервер, на сервере получать id вариантов и делать запросы у useProduct(id),
// получать варианты и вместе со всеми вариантами ренедрить список товаров
const { data: productData } = useGetProductsList()
const productCardData = computed(() =>
productData?.value?.map(product => ({
id: product?.id,
name: product?.name,
price: product?.price,
variations: product?.variations,
images: product?.images?.slice(0, 5),
colors: getAttribute(product?.attributes, 'color')?.options,
})) ?? [],
)
return {
productCardData,
}
}