import style from "../styles/section.module.css" import { Button, Skeleton } from '@chakra-ui/react' import { useQuery } from 'react-query' import SmoothRender from "~/components/ui/smooth-render" import clsxm from "~/libs/clsxm" import { IPromotion } from '~/types/promotion' import { useModalStore } from "../stores/useModalStore" import ProductPromoCard from './Card' import ProductPromoModal from "./Modal" import { IProductDetail } from '~/types/product'; type Props = { productId: number; product: IProductDetail; } const ProductPromoSection = ({ product, productId }: Props) => { const promotionsQuery = useQuery({ queryKey: [`promotions.highlight`, productId], queryFn: async () => await fetch(`/api/product-variant/${productId}/promotion/highlight`).then((res) => res.json()) as { data: IPromotion[] } }) const promotions = promotionsQuery.data const { openModal } = useModalStore() return ( 0) || false} height='450px' duration='700ms' > {promotions?.data && promotions?.data.length > 0 && (
Promo Tersedia
)} 0 })} > {promotions?.data.map((promotion) => (
))}
) } export default ProductPromoSection