From fdfb47c3a825258b871ac5921605642e5e05fdd8 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 12:04:20 +0700
Subject: fix

---
 src/lib/variant/components/VariantGroupCard.jsx | 33 +++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 src/lib/variant/components/VariantGroupCard.jsx

(limited to 'src/lib/variant/components/VariantGroupCard.jsx')

diff --git a/src/lib/variant/components/VariantGroupCard.jsx b/src/lib/variant/components/VariantGroupCard.jsx
new file mode 100644
index 00000000..fd4f9b4d
--- /dev/null
+++ b/src/lib/variant/components/VariantGroupCard.jsx
@@ -0,0 +1,33 @@
+import { useState } from "react"
+import VariantCard from "./VariantCard"
+
+const VariantGroupCard = ({
+  variants,
+  ...props
+}) => {
+  const [ showAll, setShowAll ] = useState(false)
+  const variantsToShow = showAll ? variants : variants.slice(0, 2)
+
+  return (
+    <>
+      { variantsToShow?.map((variant, index) => (
+        <VariantCard
+          key={index}
+          product={variant}
+          {...props}
+        />
+      )) }
+      { variants.length > 2 && (
+        <button 
+          type="button" 
+          className="btn-light py-2 w-full"
+          onClick={() => setShowAll(!showAll)}
+        >
+          { !showAll ? `Lihat Semua +${variants.length - variantsToShow.length}` : 'Tutup' }
+        </button>
+      ) }
+    </>
+  )
+}
+
+export default VariantGroupCard
\ No newline at end of file
-- 
cgit v1.2.3

