From 9c2304361f829a8f0a28460ea8f14bebd00b2939 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 28 Apr 2023 14:43:19 +0700 Subject: category --- src/lib/category/components/Category.jsx | 7 +++--- src/pages/shop/category/[slug].jsx | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/pages/shop/category/[slug].jsx (limited to 'src') diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx index 9f34362c..eddedd24 100644 --- a/src/lib/category/components/Category.jsx +++ b/src/lib/category/components/Category.jsx @@ -1,6 +1,7 @@ import odooApi from '@/core/api/odooApi' import Link from '@/core/components/elements/Link/Link' import DesktopView from '@/core/components/views/DesktopView' +import { createSlug } from '@/core/utils/slug' import { useEffect, useState } from 'react' const Category = () => { @@ -32,7 +33,7 @@ const Category = () => { {categories.map((category) => (
{category.name} @@ -42,7 +43,7 @@ const Category = () => { {category.childs.map((child1Category) => (
{child1Category.name} @@ -50,7 +51,7 @@ const Category = () => {
{child1Category.childs.map((child2Category) => ( diff --git a/src/pages/shop/category/[slug].jsx b/src/pages/shop/category/[slug].jsx new file mode 100644 index 00000000..2c5d9f3e --- /dev/null +++ b/src/pages/shop/category/[slug].jsx @@ -0,0 +1,40 @@ +import dynamic from 'next/dynamic' +import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug' +import { useRouter } from 'next/router' +import _ from 'lodash' +import Seo from '@/core/components/Seo' + +const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout')) +const ProductSearch = dynamic(() => import('@/lib/product/components/ProductSearch')) + +export default function CategoryDetail() { + const router = useRouter() + const { slug = '' } = router.query + + const categoryName = getNameFromSlug(slug) + const categoryId = getIdFromSlug(slug) + const query = { + fq: `manufacture_id_i:${categoryId}` + } + return ( + + + + {!_.isEmpty(router.query) && ( + + )} + + ) +} -- cgit v1.2.3