From 518f731977223d96c209e1318444e07970517e38 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 6 Nov 2025 13:00:49 +0700 Subject: Cr renca --- .../modules/product-detail/components/Image.tsx | 4 +- .../product-detail/components/PriceAction.tsx | 14 ++-- .../product-detail/styles/price-action.module.css | 2 +- src/core/components/elements/Navbar/Search.jsx | 84 +++++++++++----------- .../components/Product/ProductDesktopVariant.jsx | 4 +- .../components/Product/ProductMobileVariant.jsx | 4 +- src/lib/product/components/ProductCard.jsx | 8 +-- 7 files changed, 62 insertions(+), 58 deletions(-) diff --git a/src-migrate/modules/product-detail/components/Image.tsx b/src-migrate/modules/product-detail/components/Image.tsx index d99b683c..c9687bf0 100644 --- a/src-migrate/modules/product-detail/components/Image.tsx +++ b/src-migrate/modules/product-detail/components/Image.tsx @@ -92,7 +92,7 @@ const Image = ({ product }: Props) => { - {flashSale.remaining_time > 0 && ( + {/* {flashSale.remaining_time > 0 && (
{
- )} + )} */} ); }; diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 03148150..e5f62553 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -174,7 +174,7 @@ const PriceAction = ({ product }: Props) => { // Tidak ada discount bawaan, tapi ada voucher → tampilkan harga setelah voucher <>
@@ -232,7 +232,7 @@ const PriceAction = ({ product }: Props) => { // Tidak ada discount bawaan, tapi ada voucher → tampilkan harga setelah voucher <>
@@ -285,7 +285,7 @@ const PriceAction = ({ product }: Props) => {
-
+
{/* Qty */}
- + {/* * {qtyPickUp} barang bisa di pickup - + */} {/* ===== MOBILE: grid kiri-kanan, kanan hanya qty ===== */} @@ -381,11 +381,11 @@ const PriceAction = ({ product }: Props) => { )}
- {qtyPickUp > 0 && ( + {/* {qtyPickUp > 0 && (
* {qtyPickUp} barang bisa di pickup
- )} + )} */}
{/* Kanan: hanya qty, rata kanan */} diff --git a/src-migrate/modules/product-detail/styles/price-action.module.css b/src-migrate/modules/product-detail/styles/price-action.module.css index b94c33f7..def14e86 100644 --- a/src-migrate/modules/product-detail/styles/price-action.module.css +++ b/src-migrate/modules/product-detail/styles/price-action.module.css @@ -19,7 +19,7 @@ } .disc-badge { - @apply bg-danger-500 px-2 py-1.5 rounded text-white text-caption-2; + @apply bg-danger-500 px-2 py-1 rounded text-white text-caption-2; } .disc-price { diff --git a/src/core/components/elements/Navbar/Search.jsx b/src/core/components/elements/Navbar/Search.jsx index e4f89103..d044d6a0 100644 --- a/src/core/components/elements/Navbar/Search.jsx +++ b/src/core/components/elements/Navbar/Search.jsx @@ -1,68 +1,72 @@ -import searchSuggestApi from '@/core/api/searchSuggestApi' -import { MagnifyingGlassIcon } from '@heroicons/react/24/outline' -import { useCallback, useEffect, useRef, useState } from 'react' -import Link from '../Link/Link' -import { useRouter } from 'next/router' -import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug' +import searchSuggestApi from '@/core/api/searchSuggestApi'; +import { MagnifyingGlassIcon } from '@heroicons/react/24/outline'; +import { useCallback, useEffect, useRef, useState } from 'react'; +import Link from '../Link/Link'; +import { useRouter } from 'next/router'; +import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug'; const Search = () => { - const router = useRouter() - const queryRef = useRef() - const { slug = '' } = router.query - const [query, setQuery] = useState(router.query.q || '') - const [suggestions, setSuggestions] = useState([]) - const [segment, setSegment] = useState(null) - const [optionSegment, setOptionSegment] = useState(null) - const [optoinSelected, setOptionSelected] = useState(getNameFromSlug(slug) || 'default') - const [pathSegments, setPathSegments] = useState(router?.asPath.split('/') || []) + const router = useRouter(); + const queryRef = useRef(); + const { slug = '' } = router.query; + const [query, setQuery] = useState(router.query.q || ''); + const [suggestions, setSuggestions] = useState([]); + const [segment, setSegment] = useState(null); + const [optionSegment, setOptionSegment] = useState(null); + const [optoinSelected, setOptionSelected] = useState( + getNameFromSlug(slug) || 'default' + ); + const [pathSegments, setPathSegments] = useState( + router?.asPath.split('/') || [] + ); const loadSuggestion = useCallback(() => { if (query && document.activeElement == queryRef.current) { searchSuggestApi({ query }).then((response) => { - setSuggestions(response.data?.suggestions || []) - }) + setSuggestions(response.data?.suggestions || []); + }); } else { - setSuggestions([]) + setSuggestions([]); } - }, [query]) + }, [query]); useEffect(() => { if (query && document.activeElement == queryRef.current) { - loadSuggestion() + loadSuggestion(); } else { - setSuggestions([]) + setSuggestions([]); } - setFilterSearch() - }, [loadSuggestion, query]) + setFilterSearch(); + }, [loadSuggestion, query]); const handleSubmit = (e) => { - e.preventDefault() + e.preventDefault(); if (optionSegment && optoinSelected !== 'default' && optoinSelected) { - router.push(`/shop/${segment}/${slug}?q=${query}`) + router.push(`/shop/${segment}/${slug}?q=${query}`); } else { if (query) { - router.push(`/shop/search?q=${query}`) + router.push(`/shop/search?q=${query}`); } else { - queryRef.current.focus() + queryRef.current.focus(); } } - } + }; const handleSelectChange = async (e) => { - await setOptionSelected(e.target.value) - } + await setOptionSelected(e.target.value); + }; const setFilterSearch = async () => { if (router.pathname.includes('brands') && pathSegments[3]) { - await setSegment(pathSegments[2]) - await setOptionSegment(getNameFromSlug(slug)) + await setSegment(pathSegments[2]); + await setOptionSegment(getNameFromSlug(slug)); } - } + }; const onInputBlur = () => { setTimeout(() => { - setSuggestions([]) - }, 100) - } + setSuggestions([]); + }, 100); + }; return ( <> @@ -84,7 +88,7 @@ const Search = () => { className={`form-input p-3 ${ segment ? 'rounded-l-none border-l-0' : '' } rounded-r-none border-r-0 focus:border-gray_r-6`} - placeholder='Ketik nama, part number, merk' + placeholder='Ketik nama, part number, merek' value={query} onChange={(e) => setQuery(e.target.value)} onBlur={onInputBlur} @@ -115,7 +119,7 @@ const Search = () => {
- ) -} + ); +}; -export default Search +export default Search; diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 24a8498a..64a6419a 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -639,14 +639,14 @@ const ProductDesktopVariant = ({ )}
- {qtyPickUp > 0 && ( + {/* {qtyPickUp > 0 && ( <>
* {qtyPickUp} barang bisa di pickup
- )} + )} */}
- {qtyPickUp > 0 && ( + {/* {qtyPickUp > 0 && (
* {qtyPickUp} barang bisa di pickup
- )} + )} */}
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 9523e937..7c1810e3 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -342,7 +342,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {(product?.stockTotal > 0 || product?.qtySold > 0) && (
{product?.stockTotal > 0 && ( -
+
Ready Stock
)} @@ -536,7 +536,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {/* baris harga sekarang + harga coret */}
{/* harga setelah voucher */} - + {currencyFormat(finalAfterVoucher)} @@ -596,7 +596,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {(product?.stockTotal > 0 || product?.qtySold > 0) && (
{product?.stockTotal > 0 && ( -
+
Ready Stock
)} @@ -818,7 +818,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
{product?.stockTotal > 0 && ( -
Ready Stock
+
Ready Stock
)} {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} {product?.qtySold > 0 && ( -- cgit v1.2.3