diff options
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/api/shop/product-homepage.js | 3 | ||||
| -rw-r--r-- | src/pages/api/shop/search.js | 21 | ||||
| -rw-r--r-- | src/pages/index.jsx | 55 | ||||
| -rw-r--r-- | src/pages/shop/category/[slug].jsx | 9 | ||||
| -rw-r--r-- | src/pages/shop/lob/[slug].jsx | 48 | ||||
| -rw-r--r-- | src/pages/tracking-order.jsx | 26 |
6 files changed, 19 insertions, 143 deletions
diff --git a/src/pages/api/shop/product-homepage.js b/src/pages/api/shop/product-homepage.js index 61732c77..02c01ee0 100644 --- a/src/pages/api/shop/product-homepage.js +++ b/src/pages/api/shop/product-homepage.js @@ -36,8 +36,7 @@ const respoonseMap = (productHomepage, products) => { name: productHomepage.name_s, image: productHomepage.image_s, url: productHomepage.url_s, - products: products, - categoryIds: productHomepage.category_id_ids, + products: products } return productMapped diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 7b7a80b5..87d7c580 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -46,10 +46,7 @@ export default async function handler(req, res) { paramOrderBy += ''; break; } - - let checkQ = q.trim().split(/[\s\+\-\!\(\)\{\}\[\]\^"~\*\?:\\\/]+/); - let newQ = checkQ.length > 1 ? escapeSolrQuery(q) + '*' : escapeSolrQuery(q); - + let offset = (page - 1) * limit; let parameter = [ 'facet.field=manufacture_name_s', @@ -58,12 +55,12 @@ export default async function handler(req, res) { 'indent=true', `facet.query=${escapeSolrQuery(q)}`, `q.op=${operation}`, - `q=${newQ}`, + `q=${escapeSolrQuery(q)}`, 'qf=name_s', `start=${parseInt(offset)}`, `rows=${limit}`, `sort=${paramOrderBy}`, - `fq=-publish_b:false, product_rating_f:[8 TO *], price_tier1_v2_f:[1 TO *]`, + `fq=-publish_b:false, product_rating_f:[13 TO *], discount_tier1_v2_f:[1 TO *]`, ]; @@ -85,10 +82,7 @@ export default async function handler(req, res) { parameter.push( `fq=${brand .split(',') - .map( - (manufacturer) => - `manufacture_name:"${encodeURIComponent(manufacturer)}"` - ) + .map((manufacturer) => `manufacture_name:"${encodeURIComponent(manufacturer)}"`) .join(' OR ')}` ); if (category) @@ -132,14 +126,12 @@ export default async function handler(req, res) { const escapeSolrQuery = (query) => { if (query == '*') return query; - - query = query.replace(/-/g, ' '); - const specialChars = /([\+\!\(\)\{\}\[\]\^"~\*\?:\\\/])/g; + const specialChars = /([\+\-\!\(\)\{\}\[\]\^"~\*\?:\\\/])/g; const words = query.split(/\s+/); const escapedWords = words.map((word) => { if (specialChars.test(word)) { - return word.replace(specialChars, '\\$1'); + return `"${word.replace(specialChars, '\\$1')}"`; } return word; }); @@ -147,7 +139,6 @@ const escapeSolrQuery = (query) => { return escapedWords.join(' '); }; - /*const productResponseMap = (products, pricelist) => { return products.map((product) => { let price = product.price_tier1_v2_f || 0 diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 5a443478..8af963fb 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,5 +1,6 @@ import dynamic from 'next/dynamic'; -import { useEffect, useRef, useState } from 'react'; +import { useRef } from 'react'; + import { HeroBannerSkeleton } from '@/components/skeleton/BannerSkeleton'; import { PopularProductSkeleton } from '@/components/skeleton/PopularProductSkeleton'; import Seo from '@/core/components/Seo'; @@ -8,13 +9,10 @@ import DesktopView from '@/core/components/views/DesktopView'; import MobileView from '@/core/components/views/MobileView'; import { FlashSaleSkeleton } from '@/lib/flashSale/skeleton/FlashSaleSkeleton'; import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBrandSkeleton'; -import BannerPromoSkeleton from '@/lib/home/components/Skeleton/BannerPromoSkeleton'; import PromotinProgram from '@/lib/promotinProgram/components/HomePage'; import PagePopupIformation from '~/modules/popup-information'; -import CategoryPilihan from '../lib/home/components/CategoryPilihan'; -import odooApi from '@/core/api/odooApi'; +import useProductDetail from '~/modules/product-detail/stores/useProductDetail'; import { getAuth } from '~/libs/auth'; -// import { getAuth } from '~/libs/auth'; const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout') @@ -46,9 +44,9 @@ const FlashSale = dynamic( } ); -// const ProgramPromotion = dynamic(() => -// import('@/lib/home/components/PromotionProgram') -// ); +const ProgramPromotion = dynamic(() => + import('@/lib/home/components/PromotionProgram') +); const BannerSection = dynamic(() => import('@/lib/home/components/BannerSection') @@ -56,23 +54,12 @@ 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({categoryId}) { +export default function Home() { const bannerRef = useRef(null); const wrapperRef = useRef(null); @@ -83,18 +70,6 @@ export default function Home({categoryId}) { 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 @@ -132,24 +107,20 @@ export default function Home({categoryId}) { </div> <div className='my-16 flex flex-col gap-y-8'> - <div className='my-16 flex flex-col gap-y-8'> <ServiceList /> <div id='flashsale'> <PreferredBrand /> </div> {!auth?.feature?.soApproval && ( <> - {/* <ProgramPromotion /> <FlashSale /> */} + <ProgramPromotion /> <FlashSale /> </> )} <PromotinProgram /> - <CategoryPilihan categories={dataCategories}/> - <CategoryDynamic/> <CategoryHomeId /> <BannerSection /> <CustomerReviews /> </div> - </div> </div> </DesktopView> @@ -157,7 +128,7 @@ export default function Home({categoryId}) { <DelayRender renderAfter={200}> <HeroBanner /> </DelayRender> - <div className='flex flex-col gap-y-4 my-6'> + <div className='flex flex-col gap-y-12 my-6'> <DelayRender renderAfter={400}> <ServiceList /> </DelayRender> @@ -169,7 +140,7 @@ export default function Home({categoryId}) { {!auth?.feature?.soApproval && ( <> <DelayRender renderAfter={400}> - {/* <ProgramPromotion /> */} + <ProgramPromotion /> </DelayRender> <DelayRender renderAfter={600}> <FlashSale /> @@ -179,10 +150,6 @@ export default function Home({categoryId}) { <DelayRender renderAfter={600}> <PromotinProgram /> </DelayRender> - <DelayRender renderAfter={600}> - <CategoryPilihan categories={dataCategories}/> - <CategoryDynamicMobile/> - </DelayRender> <DelayRender renderAfter={800}> <PopularProduct /> </DelayRender> @@ -197,4 +164,4 @@ export default function Home({categoryId}) { </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 11840d47..1afe30bf 100644 --- a/src/pages/shop/category/[slug].jsx +++ b/src/pages/shop/category/[slug].jsx @@ -5,8 +5,6 @@ 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') @@ -14,14 +12,10 @@ 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); @@ -49,9 +43,8 @@ export default function CategoryDetail() { <Breadcrumb categoryId={categoryId} /> - {!_.isEmpty(router.query) && ( - <ProductSearch query={query} categories ={categoryId} prefixUrl={`/shop/category/${slug}`} /> + <ProductSearch query={query} prefixUrl={`/shop/category/${slug}`} /> )} </BasicLayout> ); diff --git a/src/pages/shop/lob/[slug].jsx b/src/pages/shop/lob/[slug].jsx deleted file mode 100644 index d939c25c..00000000 --- a/src/pages/shop/lob/[slug].jsx +++ /dev/null @@ -1,48 +0,0 @@ -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> - ); -} diff --git a/src/pages/tracking-order.jsx b/src/pages/tracking-order.jsx deleted file mode 100644 index 18e1a78a..00000000 --- a/src/pages/tracking-order.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import Seo from '@/core/components/Seo' -import dynamic from 'next/dynamic' -import SimpleFooter from '@/core/components/elements/Footer/SimpleFooter'; -import BasicLayout from '@/core/components/layouts/BasicLayout'; -import DesktopView from '@/core/components/views/DesktopView'; -import MobileView from '@/core/components/views/MobileView'; -const PageTrackingOrder = dynamic(() => import('@/lib/tracking-order/component/TrackingOrder')) - -export default function TrackingOrder() { - return ( - <> - <Seo title='Tracking Order - Indoteknik.com' /> - - <DesktopView> - <BasicLayout> - <PageTrackingOrder/> - </BasicLayout> - </DesktopView> - - <MobileView> - - <SimpleFooter /> - </MobileView> - </> - ); -} |
