From f1910544cf6df50bcb175b66b604f5903f6ae3fa Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 27 Jul 2024 13:34:00 +0700
Subject: <iman> update category management for lob

---
 src/lib/lob/components/Breadcrumb.jsx | 55 +++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 src/lib/lob/components/Breadcrumb.jsx

(limited to 'src/lib/lob/components/Breadcrumb.jsx')

diff --git a/src/lib/lob/components/Breadcrumb.jsx b/src/lib/lob/components/Breadcrumb.jsx
new file mode 100644
index 00000000..04d9a691
--- /dev/null
+++ b/src/lib/lob/components/Breadcrumb.jsx
@@ -0,0 +1,55 @@
+import odooApi from '@/core/api/odooApi'
+import { createSlug } from '@/core/utils/slug'
+import {
+  Breadcrumb as ChakraBreadcrumb,
+  BreadcrumbItem,
+  BreadcrumbLink,
+  Skeleton
+} from '@chakra-ui/react'
+import Link from 'next/link'
+import React from 'react'
+import { useQuery } from 'react-query'
+
+/**
+ * Render a breadcrumb component.
+ *
+ * @param {object} categoryId - The ID of the category.
+ * @return {JSX.Element} The breadcrumb component.
+ */
+const Breadcrumb = ({ categoryId }) => {
+    const breadcrumbs = useQuery(
+        `lob-breadcrumbs/${categoryId}`,
+        async () => await odooApi('GET', `/api/v1/lob_homepage?lob_id=${categoryId}`)
+    )
+  return (
+    <div className='container mx-auto py-4 md:py-6'>
+      <Skeleton isLoaded={!breadcrumbs.isLoading} className='w-2/3'>
+        <ChakraBreadcrumb>
+          <BreadcrumbItem>
+            <BreadcrumbLink as={Link} href='/' className='!text-danger-500 whitespace-nowrap'>
+              Home
+            </BreadcrumbLink>
+          </BreadcrumbItem>
+
+          {breadcrumbs.data?.map((category, index) => (
+            <BreadcrumbItem key={index} isCurrentPage={index === breadcrumbs.data.length - 1}>
+              {index === breadcrumbs.data.length - 1 ? (
+                <BreadcrumbLink className='whitespace-nowrap'>{category.industries}</BreadcrumbLink>
+              ) : (
+                <BreadcrumbLink
+                  as={Link}
+                  href={createSlug('/shop/lob/', category.industries, category.id)}
+                  className='!text-danger-500 whitespace-nowrap'
+                >
+                  {category.industries}
+                </BreadcrumbLink>
+              )}
+            </BreadcrumbItem>
+          ))}
+        </ChakraBreadcrumb>
+      </Skeleton>
+    </div>
+  )
+}
+
+export default Breadcrumb
-- 
cgit v1.2.3


From 556e7e226a2043d43bc55bf0ff2118294bb9f330 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 29 Jul 2024 13:32:39 +0700
Subject: <iman> update lob category

---
 src/lib/lob/components/Breadcrumb.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/lib/lob/components/Breadcrumb.jsx')

diff --git a/src/lib/lob/components/Breadcrumb.jsx b/src/lib/lob/components/Breadcrumb.jsx
index 04d9a691..5722fd39 100644
--- a/src/lib/lob/components/Breadcrumb.jsx
+++ b/src/lib/lob/components/Breadcrumb.jsx
@@ -19,7 +19,7 @@ import { useQuery } from 'react-query'
 const Breadcrumb = ({ categoryId }) => {
     const breadcrumbs = useQuery(
         `lob-breadcrumbs/${categoryId}`,
-        async () => await odooApi('GET', `/api/v1/lob_homepage?lob_id=${categoryId}`)
+        async () => await odooApi('GET', `/api/v1/lob_homepage/${categoryId}/category_id`)
     )
   return (
     <div className='container mx-auto py-4 md:py-6'>
@@ -31,7 +31,7 @@ const Breadcrumb = ({ categoryId }) => {
             </BreadcrumbLink>
           </BreadcrumbItem>
 
-          {breadcrumbs.data?.map((category, index) => (
+          {breadcrumbs?.data?.map((category, index) => (
             <BreadcrumbItem key={index} isCurrentPage={index === breadcrumbs.data.length - 1}>
               {index === breadcrumbs.data.length - 1 ? (
                 <BreadcrumbLink className='whitespace-nowrap'>{category.industries}</BreadcrumbLink>
-- 
cgit v1.2.3

