summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-08-20 09:14:52 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-08-20 09:14:52 +0000
commit7388f27d1778aaa66191b44d725ce7c3e3e4ddd8 (patch)
tree7fdef4f99f0f42e2d99a40bfd5b81f1ca5f4ef30 /src/pages
parent6d302bb338e26810a7f90326b84086217f1f4ae0 (diff)
parent5c5eef9d62efd83f52f7c37dacb94d50ff7cb915 (diff)
Merged in Feature/category-management (pull request #248)
Feature/category management
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/api/shop/product-homepage.js3
-rw-r--r--src/pages/index.jsx57
-rw-r--r--src/pages/shop/category/[slug].jsx9
-rw-r--r--src/pages/shop/lob/[slug].jsx48
4 files changed, 103 insertions, 14 deletions
diff --git a/src/pages/api/shop/product-homepage.js b/src/pages/api/shop/product-homepage.js
index 02c01ee0..61732c77 100644
--- a/src/pages/api/shop/product-homepage.js
+++ b/src/pages/api/shop/product-homepage.js
@@ -36,7 +36,8 @@ const respoonseMap = (productHomepage, products) => {
name: productHomepage.name_s,
image: productHomepage.image_s,
url: productHomepage.url_s,
- products: products
+ products: products,
+ categoryIds: productHomepage.category_id_ids,
}
return productMapped
diff --git a/src/pages/index.jsx b/src/pages/index.jsx
index 4493fe31..4d6e59e0 100644
--- a/src/pages/index.jsx
+++ b/src/pages/index.jsx
@@ -1,6 +1,5 @@
import dynamic from 'next/dynamic';
-import { useRef } from 'react';
-
+import { useEffect, useRef, useState } from 'react';
import { HeroBannerSkeleton } from '@/components/skeleton/BannerSkeleton';
import { PopularProductSkeleton } from '@/components/skeleton/PopularProductSkeleton';
import Seo from '@/core/components/Seo';
@@ -12,8 +11,11 @@ import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBran
import BannerPromoSkeleton from '@/lib/home/components/Skeleton/BannerPromoSkeleton';
import PromotinProgram from '@/lib/promotinProgram/components/HomePage';
import PagePopupIformation from '~/modules/popup-information';
-import useProductDetail from '~/modules/product-detail/stores/useProductDetail';
+import CategoryPilihan from '../lib/home/components/CategoryPilihan';
+import odooApi from '@/core/api/odooApi';
import { getAuth } from '~/libs/auth';
+// import { getAuth } from '~/libs/auth';
+import useProductDetail from '~/modules/product-detail/stores/useProductDetail';
const BasicLayout = dynamic(() =>
import('@/core/components/layouts/BasicLayout')
@@ -58,12 +60,23 @@ const BannerSection = dynamic(() =>
const CategoryHomeId = dynamic(() =>
import('@/lib/home/components/CategoryHomeId')
);
+
+const CategoryDynamic = dynamic(() =>
+ import('@/lib/home/components/CategoryDynamic')
+);
+
+const CategoryDynamicMobile = dynamic(() =>
+ import('@/lib/home/components/CategoryDynamicMobile')
+);
+
const CustomerReviews = dynamic(() =>
import('@/lib/review/components/CustomerReviews')
);
const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'));
-export default function Home() {
+
+
+export default function Home({categoryId}) {
const bannerRef = useRef(null);
const wrapperRef = useRef(null);
@@ -74,7 +87,19 @@ export default function Home() {
bannerRef.current?.querySelector(':first-child')?.clientHeight + 'px';
};
+ useEffect(() => {
+ const loadCategories = async () => {
+ const getCategories = await odooApi('GET', '/api/v1/category/child?partner_id='+{categoryId})
+ if(getCategories){
+ setDataCategories(getCategories)
+ }
+ }
+ loadCategories()
+ }, [])
+
+ const [dataCategories, setDataCategories] = useState([])
return (
+ <>
<BasicLayout>
<Seo
title='Indoteknik.com: B2B Industrial Supply & Solution'
@@ -82,11 +107,9 @@ export default function Home() {
additionalMetaTags={[
{
name: 'keywords',
- content:
- 'indoteknik, indoteknik.com, toko teknik, toko perkakas, jual genset, jual fogging, jual krisbow, harga krisbow, harga alat safety, harga pompa air',
+ content: 'indoteknik, indoteknik.com, toko teknik, toko perkakas, jual genset, jual fogging, jual krisbow, harga krisbow, harga alat safety, harga pompa air',
},
- ]}
- />
+ ]} />
<PagePopupIformation />
@@ -126,18 +149,21 @@ export default function Home() {
</>
)}
<PromotinProgram />
+ {dataCategories &&(
+ <CategoryPilihan categories={dataCategories} />
+ )}
+ <CategoryDynamic />
<CategoryHomeId />
<BannerSection />
<CustomerReviews />
</div>
</div>
- </DesktopView>
-
- <MobileView>
+ </DesktopView>
+ <MobileView>
<DelayRender renderAfter={200}>
<HeroBanner />
</DelayRender>
- <div className='flex flex-col gap-y-12 my-6'>
+ <div className='flex flex-col gap-y-4 my-6'>
<DelayRender renderAfter={400}>
<ServiceList />
</DelayRender>
@@ -159,6 +185,12 @@ export default function Home() {
<DelayRender renderAfter={600}>
<PromotinProgram />
</DelayRender>
+ <DelayRender renderAfter={600}>
+ {dataCategories &&(
+ <CategoryPilihan categories={dataCategories} />
+ )}
+ <CategoryDynamicMobile />
+ </DelayRender>
<DelayRender renderAfter={800}>
<PopularProduct />
</DelayRender>
@@ -172,5 +204,6 @@ export default function Home() {
</div>
</MobileView>
</BasicLayout>
+ </>
);
} \ No newline at end of file
diff --git a/src/pages/shop/category/[slug].jsx b/src/pages/shop/category/[slug].jsx
index 1afe30bf..11840d47 100644
--- a/src/pages/shop/category/[slug].jsx
+++ b/src/pages/shop/category/[slug].jsx
@@ -5,6 +5,8 @@ import { useRouter } from 'next/router';
import Seo from '@/core/components/Seo';
import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
import Breadcrumb from '@/lib/category/components/Breadcrumb';
+import { useEffect, useState } from 'react';
+import odooApi from '@/core/api/odooApi';
const BasicLayout = dynamic(() =>
import('@/core/components/layouts/BasicLayout')
@@ -12,10 +14,14 @@ const BasicLayout = dynamic(() =>
const ProductSearch = dynamic(() =>
import('@/lib/product/components/ProductSearch')
);
+const CategorySection = dynamic(() =>
+ import('@/lib/product/components/CategorySection')
+)
export default function CategoryDetail() {
const router = useRouter();
const { slug = '', page = 1 } = router.query;
+ const [dataCategories, setDataCategories] = useState([])
const categoryName = getNameFromSlug(slug);
const categoryId = getIdFromSlug(slug);
@@ -43,8 +49,9 @@ export default function CategoryDetail() {
<Breadcrumb categoryId={categoryId} />
+
{!_.isEmpty(router.query) && (
- <ProductSearch query={query} prefixUrl={`/shop/category/${slug}`} />
+ <ProductSearch query={query} categories ={categoryId} prefixUrl={`/shop/category/${slug}`} />
)}
</BasicLayout>
);
diff --git a/src/pages/shop/lob/[slug].jsx b/src/pages/shop/lob/[slug].jsx
new file mode 100644
index 00000000..d939c25c
--- /dev/null
+++ b/src/pages/shop/lob/[slug].jsx
@@ -0,0 +1,48 @@
+import _ from 'lodash';
+import dynamic from 'next/dynamic';
+import { useRouter } from 'next/router';
+import Seo from '@/core/components/Seo';
+import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
+import Breadcrumb from '../../../lib/lob/components/Breadcrumb';
+import { useEffect, useState } from 'react';
+import odooApi from '@/core/api/odooApi';
+import { div } from 'lodash-contrib';
+
+const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout'));
+const ProductSearch = dynamic(() => import('@/lib/product/components/ProductSearch'));
+const CategorySection = dynamic(() => import('@/lib/product/components/CategorySection'));
+
+export default function CategoryDetail() {
+ const router = useRouter();
+ const { slug = '', page = 1 } = router.query;
+ const [dataLob, setDataLob] = useState([]);
+ const [finalQuery, setFinalQuery] = useState({});
+ const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
+ const [data, setData] = useState([])
+ const dataIdCategories = []
+
+ const categoryName = getNameFromSlug(slug);
+ const lobId = getIdFromSlug(slug);
+ const q = router?.query.q || null;
+
+ return (
+ <BasicLayout>
+ <Seo
+ title={`Beli ${categoryName} di Indoteknik`}
+ description={`Jual ${categoryName} Kirim Jakarta Surabaya Semarang Makassar Manado Denpasar Balikpapan Medan Palembang Lampung Bali Bandung Makassar Manado.`}
+ additionalMetaTags={[
+ {
+ property: 'keywords',
+ content: `Jual ${categoryName}, harga ${categoryName}, ${categoryName} murah, toko ${categoryName}, ${categoryName} jakarta, ${categoryName} surabaya`,
+ },
+ ]}
+ />
+
+ <Breadcrumb categoryId={getIdFromSlug(slug)} />
+
+ {!_.isEmpty(router.query) && (
+ <ProductSearch query={router.query} categories={getIdFromSlug(slug)} prefixUrl={`/shop/lob/${slug}`} />
+ )}
+ </BasicLayout>
+ );
+}