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