summaryrefslogtreecommitdiff
path: root/src-migrate/modules/product-promo/components/ModalContent.tsx
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-01-04 03:07:56 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-01-04 03:07:56 +0000
commit0d33de3744f612262c12d648cd7147a2ef238a36 (patch)
tree285af0ed69169621228e252affdac958f016dab2 /src-migrate/modules/product-promo/components/ModalContent.tsx
parentbb8ee26d89842b4f9b99b48f2a7cc464c6ecc4ee (diff)
parent67398e6f10d6f7729d8f1ace7005ef13d32c5ddd (diff)
Merged in Feature/promotion-program (pull request #124)
Feature/promotion program
Diffstat (limited to 'src-migrate/modules/product-promo/components/ModalContent.tsx')
-rw-r--r--src-migrate/modules/product-promo/components/ModalContent.tsx37
1 files changed, 37 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..90cf79e7
--- /dev/null
+++ b/src-migrate/modules/product-promo/components/ModalContent.tsx
@@ -0,0 +1,37 @@
+import { useQuery } from "react-query"
+import { Skeleton } from "@chakra-ui/react"
+
+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-[70vh] max-h-[70vh]'>
+ <div className="grid grid-cols-1 gap-y-6 pb-6">
+ {promotions?.data.map((promo) => (
+ <ProductPromoCard key={promo.id} promotion={promo} />
+ ))}
+ {promotions?.data.length === 0 && (
+ <div className="py-10 rounded-lg h-fit text-center text-body-1 font-semibold text-gray-800 bg-gray-200">Belum ada promo pada kategori ini</div>
+ )}
+ </div>
+ </Skeleton>
+ )
+}
+
+export default ProductPromoModalContent \ No newline at end of file