From adc316e70faf20ea375b3e590998a36997b6b6e2 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Wed, 26 Nov 2025 14:56:36 +0700 Subject: balikin --- src/components/ui/PopularProduct.jsx | 110 +++++++++++++++++------------------ 1 file changed, 54 insertions(+), 56 deletions(-) (limited to 'src/components') diff --git a/src/components/ui/PopularProduct.jsx b/src/components/ui/PopularProduct.jsx index 0740798d..d3ae9e27 100644 --- a/src/components/ui/PopularProduct.jsx +++ b/src/components/ui/PopularProduct.jsx @@ -1,63 +1,61 @@ -import MobileView from '@/core/components/views/MobileView'; -import DesktopView from '@/core/components/views/DesktopView'; -import ProductSlider from '@/lib/product/components/ProductSlider'; -import ProductCard from '@/lib/product/components/ProductCard'; -import Link from '@/core/components/elements/Link/Link'; -import { PopularProductSkeleton } from '../skeleton/PopularProductSkeleton'; -import { useQuery } from 'react-query'; -import { popularProductApi } from '@/api/productApi'; +import { popularProductApi } from '@/api/productApi' +import MobileView from '@/core/components/views/MobileView' +import ProductSlider from '@/lib/product/components/ProductSlider' +import { useQuery } from 'react-query' +import { PopularProductSkeleton } from '../skeleton/PopularProductSkeleton' +import DesktopView from '@/core/components/views/DesktopView' +import ProductCard from '@/lib/product/components/ProductCard' +import Link from '@/core/components/elements/Link/Link' -export default function PopularProduct({ initialData }) { - const query = useQuery( - 'popularProducts', - popularProductApi(), - { - initialData: initialData ? { products: initialData.products } : undefined, - refetchOnMount: false - } - ); +const PopularProduct = () => { + const popularProduct = useQuery('popularProduct', popularProductApi()) - if (query.isLoading) return ; - - const data = query.data; - - if (!data) return null; + if (popularProduct.isLoading) return return ( - <> - {/* Mobile */} - -
-
-

Produk Ready Stock

- -

Lihat Semua

- + popularProduct.data && ( + <> + +
+

+ Produk Ready Stock +

+ +

Lihat Semua

+
+
- - -
- - - {/* Desktop */} - -
-
-

Produk Ready Stock

- -

Lihat Semua

- + + + +
+
+

+ Produk Ready Stock +

+ +

Lihat Semua

+ +
+
+ {popularProduct.data && + popularProduct.data.products.map((product) => ( +
+ +
+ ))} +
- -
- {data.products.map((product) => ( -
- -
- ))} -
-
- - - ); + + + ) + ) } + +export default PopularProduct -- cgit v1.2.3