From bf5c3b1d48da54e0e44689412ad9de9c10cf9edb Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 23 Jul 2024 09:28:21 +0700
Subject: <iman> update category management

---
 src/lib/home/components/CategoryDynamic.jsx | 32 +++++++++--------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

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

diff --git a/src/lib/home/components/CategoryDynamic.jsx b/src/lib/home/components/CategoryDynamic.jsx
index 2edd5485..cac8a138 100644
--- a/src/lib/home/components/CategoryDynamic.jsx
+++ b/src/lib/home/components/CategoryDynamic.jsx
@@ -1,36 +1,24 @@
 import React, { useEffect, useState } from 'react';
-import {fetchProductManagementSolr} from '../hooks/useCategoryManagement';
+import useCategoryManagement  from '../hooks/useCategoryManagement';
 import NextImage from 'next/image';
 import Link from "next/link"
 import router from 'next/router';
 import { createSlug } from '@/core/utils/slug'
 
-const CategoryDynamic =    () => {
-  const [promoItems, setPromoItems] = useState([]);
-  useEffect(() => {
-    const loadPromo = async () => {
-      
-      try {
-        const items = await fetchProductManagementSolr();
-        setPromoItems(items);
-
-      } catch (loadError) {
-        // console.error("Error loading promo items:", loadError)
-      }
-    }
-      loadPromo()
-  },[]);
+const CategoryDynamic =  () => {
+  const { categoryManagement } = useCategoryManagement()
+  
   return (
     <div>
-      {promoItems && promoItems.map((category) => (
+      {categoryManagement && categoryManagement.data?.map((category) => (
         <div key={category.id}>
           <div className='bagian-judul flex flex-row justify-start items-center gap-3 mb-4 mt-4'>
               <div className='font-semibold sm:text-h-lg mr-2'>{category.name}</div>
               <p className='text-gray_r-10 text-sm'>999 rb+ Produk tersedia</p>
-              <Link href={createSlug('/shop/category/', category?.name, category?.category_id)} className="!text-red-500 font-semibold">Lihat Semua</Link>
+              <Link href={createSlug('/shop/category/', category?.name, category?.categoryIdI)} className="!text-red-500 font-semibold">Lihat Semua</Link>
           </div>
           <div className='grid grid-cols-3 gap-2'>
-            {category.category_id2.map((index)=> (
+            {category.categories.map((index)=> (
               <div key={index.id} className='border rounded justify-start items-start'>
                 <div className='p-3'>
                     <div className='flex flex-row border rounded mb-2 justify-start items-center'>
@@ -44,13 +32,13 @@ const CategoryDynamic =    () => {
                       <div className='bagian-judul flex flex-col justify-center items-start gap-2 ml-2'>
                           <div className='font-semibold text-lg mr-2'>{index.name}</div>
                           <p className='text-gray_r-10 text-sm'>999 rb+ Produk</p>
-                          <Link href={createSlug('/shop/category/', index?.name, index?.id_level_2)} className="!text-red-500 font-semibold">Lihat Semua</Link>
+                          <Link href={createSlug('/shop/category/', index?.name, index?.idLevel2)} className="!text-red-500 font-semibold">Lihat Semua</Link>
                       </div>
                     </div>
                     <div className='grid grid-cols-2 gap-2 overflow-y-auto max-h-[240px]' >
-                        {index.child_frontend_id_i.map((x)=> (
+                        {index.childFrontendIdI.map((x)=> (
                           <div key={x.id}>
-                                <Link href={createSlug('/shop/category/', x?.name, x?.id_level_3)} className="flex flex-row gap-2 border rounded group hover:border-red-500">
+                                <Link href={createSlug('/shop/category/', x?.name, x?.idLevel3)} className="flex flex-row gap-2 border rounded group hover:border-red-500">
                                     <NextImage
                                       src={x.image? x.image : "/images/noimage.jpeg"}
                                       alt={x.name}
-- 
cgit v1.2.3

