From 0e1c9c213b6051be728944730a0e23beadd4c35e Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 24 Sep 2025 17:36:08 +0700 Subject: don cart --- .../modules/cart/components/CartSummaryMobile.tsx | 36 +++++++++++++--------- src-migrate/pages/shop/cart/cart.module.css | 14 ++++++++- src-migrate/pages/shop/cart/index.tsx | 15 +++++---- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src-migrate/modules/cart/components/CartSummaryMobile.tsx b/src-migrate/modules/cart/components/CartSummaryMobile.tsx index 02258204..7a334fed 100644 --- a/src-migrate/modules/cart/components/CartSummaryMobile.tsx +++ b/src-migrate/modules/cart/components/CartSummaryMobile.tsx @@ -29,7 +29,7 @@ const CartSummaryMobile = ({ isLoaded = false, }: Props) => { const [showPopup, setShowPopup] = useState(false); - const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; + const PPN: number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; return ( <>
- - + + {/* Left: label */} + Grand Total - - - - - Rp {formatCurrency(grandTotal || 0)} - + + {/* Right: amount + chevron */} +
+ + Rp {formatCurrency(grandTotal || 0)} + + +
+
); diff --git a/src-migrate/pages/shop/cart/cart.module.css b/src-migrate/pages/shop/cart/cart.module.css index b756fb15..af5a2abc 100644 --- a/src-migrate/pages/shop/cart/cart.module.css +++ b/src-migrate/pages/shop/cart/cart.module.css @@ -3,7 +3,7 @@ } .content { - @apply flex flex-wrap ; + @apply flex flex-wrap; } .item-wrapper { @@ -33,3 +33,15 @@ .summary-buttons-step-approval { @apply grid grid-cols-1 gap-y-3 mt-6; } + +@media (max-width: 768px) { + .item-wrapper { + /* adjust if your bar is taller/shorter */ + padding-bottom: calc(env(safe-area-inset-bottom) + 9rem); + } + + .summary-wrapper { + @apply fixed inset-x-0 bottom-0 z-50 md:sticky w-full; + } + +} \ No newline at end of file diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index 795dfa72..031aa45b 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -301,9 +301,8 @@ const CartPage: React.FC = () => { <> {/* Sticky Header */}

Keranjang Belanja

@@ -392,13 +391,17 @@ const CartPage: React.FC = () => {
+
+ {/* Cart Summary */}
{device.isMobile ? ( -- cgit v1.2.3 From c8915287bafb45925d04c79a2562cd67fdb113eb Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 25 Sep 2025 11:07:26 +0700 Subject: sort to popular when in brand page --- src/lib/product/components/ProductSearch.jsx | 44 ++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 2fb3138a..497dfec8 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -1,6 +1,6 @@ import NextImage from 'next/image'; import { useRouter } from 'next/router'; -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState, useRef } from 'react'; import { HStack, Image, Tag, TagCloseButton, TagLabel } from '@chakra-ui/react'; import axios from 'axios'; @@ -50,7 +50,33 @@ const ProductSearch = ({ const categoryId = getIdFromSlug(prefixUrl); const [data, setData] = useState([]); const [dataLob, setDataLob] = useState([]); + const appliedDefaultBrandOrder = useRef(false); + if (defaultBrand) query.brand = defaultBrand.toLowerCase(); + useEffect(() => { + if (!router.isReady) return; + + const onBrandsPage = router.pathname.includes('brands'); + const hasOrder = typeof router.query?.orderBy === 'string' && router.query.orderBy !== ''; + + if (onBrandsPage && !hasOrder && !appliedDefaultBrandOrder.current) { + let params = { + ...router.query, + orderBy: 'popular', + }; + params = _.pickBy(params, _.identity); + const qs = toQuery(params); + + // ganti URL tanpa nambah history & tanpa full reload + router.replace(`${prefixUrl}?${qs}`, undefined, { shallow: true }); + + // sinkronkan state lokal + setOrderBy('popular'); + + appliedDefaultBrandOrder.current = true; + } + }, [router.isReady, router.pathname, router.query?.orderBy, prefixUrl]); + const dataIdCategories = []; useEffect(() => { if (prefixUrl.includes('category')) { @@ -84,7 +110,7 @@ const ProductSearch = ({ if (router.asPath.includes('penawaran')) { query = { ...query, - fq:`flashsale_id_i:${router.query.penawaran} AND flashsale_price_f:[1 TO *]`, + fq: `flashsale_id_i:${router.query.penawaran} AND flashsale_price_f:[1 TO *]`, orderBy: 'flashsale-discount-desc', }; setFinalQuery(query); @@ -436,7 +462,7 @@ const ProductSearch = ({ <> {productStart + 1}- {parseInt(productStart) + parseInt(productRows) > - productFound + productFound ? productFound : parseInt(productStart) + parseInt(productRows)}  dari  @@ -597,7 +623,7 @@ const ProductSearch = ({ <> {productStart + 1}- {parseInt(productStart) + parseInt(productRows) > - productFound + productFound ? productFound : parseInt(productStart) + parseInt(productRows)}  dari  @@ -673,8 +699,8 @@ const ProductSearch = ({ href={ query?.q ? whatsappUrl('productSearch', { - name: query.q, - }) + name: query.q, + }) : whatsappUrl() } className='text-danger-500' @@ -759,9 +785,9 @@ const FilterChoicesComponent = ({ )} {brandValues?.length > 0 || - categoryValues?.length > 0 || - priceFrom || - priceTo ? ( + categoryValues?.length > 0 || + priceFrom || + priceTo ? (
-
+
)} - + {!!dataLob?.length && } + {!!dataCategories?.length && }
{products && products.map((product) => ( @@ -525,7 +524,6 @@ const ProductSearch = ({ pageCount={pageCount} currentPage={parseInt(page)} url={`${prefixUrl}?${toQuery(_.omit(query, ['page', 'fq']))}`} - // url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`} className='mt-6 mb-2' /> -- cgit v1.2.3