From baf0447595815be64312ac836e5f8bb403e4dcfc Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 19 May 2023 16:31:42 +0700
Subject: banner section and product category banner url

---
 src/lib/home/components/BannerSection.jsx | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 src/lib/home/components/BannerSection.jsx

(limited to 'src/lib/home/components/BannerSection.jsx')

diff --git a/src/lib/home/components/BannerSection.jsx b/src/lib/home/components/BannerSection.jsx
new file mode 100644
index 00000000..8459d08e
--- /dev/null
+++ b/src/lib/home/components/BannerSection.jsx
@@ -0,0 +1,30 @@
+import Link from '@/core/components/elements/Link/Link'
+import Image from 'next/image'
+
+const { useQuery } = require('react-query')
+const { default: bannerSectionApi } = require('../api/bannerSectionApi')
+
+const BannerSection = () => {
+  const fetchBannerSection = async () => await bannerSectionApi()
+  const bannerSection = useQuery('bannerSection', fetchBannerSection)
+
+  return (
+    bannerSection.data && (
+      <div className='grid grid-cols-1 sm:grid-cols-2 gap-4'>
+        {bannerSection.data?.map((banner) => (
+          <Link key={banner.id} href={banner.url}>
+            <Image
+              width={512}
+              height={256}
+              src={banner.image}
+              alt={banner.name}
+              className='h-auto w-full rounded'
+            />
+          </Link>
+        ))}
+      </div>
+    )
+  )
+}
+
+export default BannerSection
-- 
cgit v1.2.3

