diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-11-12 16:12:21 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-11-12 16:12:21 +0700 |
| commit | cd51b64b48b0c898c6ff901c1bfa23c70cd9cf1a (patch) | |
| tree | 2ce0178f645fb77d5f17238460efa9c6b62d8a90 | |
| parent | 9cbbe5e12f97af023e2f53e4add4c5e5fd9b4667 (diff) | |
<MIqdad> sementara
| -rw-r--r-- | src-migrate/modules/product-detail/components/AddToCart.tsx | 9 | ||||
| -rw-r--r-- | src-migrate/modules/product-detail/components/PriceAction.tsx | 1 | ||||
| -rw-r--r-- | src-migrate/pages/shop/product/[slug].tsx | 2 | ||||
| -rw-r--r-- | src/pages/api/shop/product-detail.js | 30 | ||||
| -rw-r--r-- | src/pages/api/shop/search.js | 2 | ||||
| -rw-r--r-- | src/pages/google_merchant/products/[page].js | 4 | ||||
| -rw-r--r-- | src/pages/google_merchant/products/index.js | 4 | ||||
| -rw-r--r-- | src/pages/sitemap/products/[page].js | 6 |
8 files changed, 38 insertions, 20 deletions
diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx index 147fd6d2..0dc39c1c 100644 --- a/src-migrate/modules/product-detail/components/AddToCart.tsx +++ b/src-migrate/modules/product-detail/components/AddToCart.tsx @@ -66,6 +66,8 @@ const AddToCart = ({ weight: '', isFlashSale: false, }); + const hasPrice = + !!product?.lowest_price && Number(product.lowest_price.price) > 0; useEffect(() => { const fetchData = async () => { @@ -183,6 +185,7 @@ const AddToCart = ({ colorScheme={btnConfig[source].colorScheme} variant={btnConfig[source].variant} className='w-full' + isDisabled={!hasPrice || status === 'loading'} > {btnConfig[source].text} </Button> @@ -194,6 +197,7 @@ const AddToCart = ({ colorScheme={btnConfig[source].colorScheme} variant={btnConfig[source].variant} className='w-full' + isDisabled={!hasPrice || status === 'loading'} > {btnConfig[source].text} </Button> @@ -208,7 +212,10 @@ const AddToCart = ({ {/* ===== MOBILE LAYOUT: konten scroll + footer fixed di dalam popup ===== */} <div className='md:hidden flex flex-col max-h-[75vh]'> {/* area scroll */} - <div className='flex-1 overflow-y-auto' style={{ scrollbarWidth: 'none' }}> + <div + className='flex-1 overflow-y-auto' + style={{ scrollbarWidth: 'none' }} + > {/* HEADER ITEM */} <div className='flex mt-4'> <div className='w-[25%]'> diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index ffc9ba40..a329d2cc 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -37,6 +37,7 @@ const PriceAction = ({ product }: Props) => { } = useProductDetail(); const [qtyPickUp, setQtyPickUp] = useState(0); const { isDesktop, isMobile } = useDevice(); + useEffect(() => { setActive(selectedVariant); if (product.variants.length > 2 && product.variants[0].price.price === 0) { diff --git a/src-migrate/pages/shop/product/[slug].tsx b/src-migrate/pages/shop/product/[slug].tsx index 058e4832..8d6558b1 100644 --- a/src-migrate/pages/shop/product/[slug].tsx +++ b/src-migrate/pages/shop/product/[slug].tsx @@ -49,7 +49,7 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async ( Array.isArray(product.variants) && product.variants.some((v) => (v?.price?.price ?? 0) > 0); - if (!hasValidVariant) return { notFound: true }; + // if (!hasValidVariant) return { notFound: true }; // bikin canonical path yang BERSIH dan KONSISTEN dari data produk, // bukan dari URL request user (jadi gak ikut ?utm_source, ?ref=, dsb) diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index faa96028..504f9dd6 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -1,26 +1,32 @@ -import { productMappingSolr, variantsMappingSolr } from '@/utils/solrMapping' -import axios from 'axios' +import { productMappingSolr, variantsMappingSolr } from '@/utils/solrMapping'; +import axios from 'axios'; export default async function handler(req, res) { try { let productTemplate = await axios( - process.env.SOLR_HOST + `/solr/product/select?q=id:${req.query.id}&q.op=OR&indent=true` - ) + process.env.SOLR_HOST + + `/solr/product/select?q=id:${req.query.id}&q.op=OR&indent=true` + ); let productVariants = await axios( process.env.SOLR_HOST + - `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100&fq=-publish_b:false AND price_tier1_v2_f:[1 TO *]` - ) - let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth - let result = productMappingSolr(productTemplate.data.response.docs, auth || false) + `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100` + // `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100&fq=-publish_b:false AND price_tier1_v2_f:[1 TO *]` + ); + let auth = + req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth; + let result = productMappingSolr( + productTemplate.data.response.docs, + auth || false + ); result[0].variants = variantsMappingSolr( productTemplate.data.response.docs[0], productVariants.data.response.docs, auth || false - ) - res.status(200).json(result) + ); + res.status(200).json(result); } catch (error) { - console.error('Error fetching data from Solr:', error) - res.status(500).json({ error: 'Internal Server Error' }) + console.error('Error fetching data from Solr:', error); + res.status(500).json({ error: 'Internal Server Error' }); } } diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 8c9782cb..a3e1b3a3 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -83,7 +83,7 @@ export default async function handler(req, res) { : `${checkQ.length}`; const filterQueries = [ - '-publish_b:false', + // '-publish_b:false', 'product_rating_f:[8 TO *]', 'price_tier1_v2_f:[1 TO *]', ]; diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index 161b6aec..2a53f7c0 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -18,7 +18,9 @@ export async function getServerSideProps({ res, query }) { page: page.replace('.xml', ''), priceFrom: 1, orderBy: 'popular', - fq: ['image_s:["" TO *] AND publish_b:true'], + fq: ['image_s:["" TO *] AND publish_b:true AND price_tier1_v2_f:[1 TO *]'], + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await variantSearchApi({ query: _.toQuery(queries) }); diff --git a/src/pages/google_merchant/products/index.js b/src/pages/google_merchant/products/index.js index b6c7bfef..d6ef413a 100644 --- a/src/pages/google_merchant/products/index.js +++ b/src/pages/google_merchant/products/index.js @@ -8,7 +8,9 @@ export async function getServerSideProps() { const queries = { limit: 1, priceFrom: 1, - fq: 'image_s:["" TO *] AND publish_b:true', + fq: 'image_s:["" TO *] AND publish_b:true AND price_tier1_v2_f:[1 TO *]', + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await variantSearchApi({ query: _.toQuery(queries) }); const { numFound } = products.response; diff --git a/src/pages/sitemap/products/[page].js b/src/pages/sitemap/products/[page].js index 421c08e3..ebb6aef7 100644 --- a/src/pages/sitemap/products/[page].js +++ b/src/pages/sitemap/products/[page].js @@ -10,9 +10,9 @@ export async function getServerSideProps({ query, res }) { const queries = { limit, page: page.replace('.xml', ''), - '-publish_b': false, - product_rating_f: '[8 TO *]', - price_tier1_v2_f: '[1 TO *]', + // '-publish_b': false, + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await productSearchApi({ query: _.toQuery(queries) }); const sitemap = create('urlset', { encoding: 'utf-8' }).att( |
