diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-12-22 17:33:46 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-12-22 17:33:46 +0700 |
| commit | 89f32128f37d99b490de7590e2116a9cfd853f89 (patch) | |
| tree | feb74cc6bd0030b291fbf3dbba9b89a7afd6ea31 /src-migrate/modules/product-promo/components/ModalContent.tsx | |
| parent | c9366090153e8aba3a673b2b77cbc8acc24e59a5 (diff) | |
Update promotion program feature
Diffstat (limited to 'src-migrate/modules/product-promo/components/ModalContent.tsx')
| -rw-r--r-- | src-migrate/modules/product-promo/components/ModalContent.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src-migrate/modules/product-promo/components/ModalContent.tsx b/src-migrate/modules/product-promo/components/ModalContent.tsx new file mode 100644 index 00000000..45995af6 --- /dev/null +++ b/src-migrate/modules/product-promo/components/ModalContent.tsx @@ -0,0 +1,33 @@ +import { useQuery } from "react-query" +import { Skeleton } from "@chakra-ui/react" +import { motion } from "framer-motion" + +import { getVariantPromoByCategory } from "~/services/variant" + +import { useModalStore } from "../stores/useModalStore" +import ProductPromoCard from "./Card" + +const ProductPromoModalContent = () => { + const { activeTab, variantId } = useModalStore() + + const promotionsQuery = useQuery( + `variant-promo:${variantId}:${activeTab}`, + async () => { + if (!variantId) return + + return getVariantPromoByCategory(variantId, activeTab) + }, + ) + + const promotions = promotionsQuery.data + + return ( + <Skeleton isLoaded={!promotionsQuery.isLoading} className='min-h-[60vh] grid grid-cols-1'> + {promotions?.data.map((promo) => ( + <ProductPromoCard key={promo.id} promotion={promo} /> + ))} + </Skeleton> + ) +} + +export default ProductPromoModalContent
\ No newline at end of file |
