From 2bfa2138be7135dc12daa98262fbaf8305698f00 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 7 Nov 2024 13:55:10 +0700 Subject: add logic quotation no po --- src/lib/transaction/components/Transaction.jsx | 116 +++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 6 deletions(-) diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 4d401037..777dd771 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -38,7 +38,9 @@ import aprpoveApi from '../api/approveApi'; import rejectApi from '../api/rejectApi'; import rejectProductApi from '../api/rejectProductApi'; import { useRouter } from 'next/router'; - +import { gtagPurchase } from '@/core/utils/googleTag'; +import { deleteItemCart } from '@/core/utils/cart'; +import axios from 'axios'; const Transaction = ({ id }) => { const router = useRouter(); const [isModalOpen, setIsModalOpen] = useState(false); @@ -48,7 +50,7 @@ const Transaction = ({ id }) => { const { transaction } = useTransaction({ id }); const statusApprovalWeb = transaction.data?.approvalStep; - + const [isLoading, setIsLoading] = useState(false); const { queryAirwayBill } = useAirwayBill({ orderId: id }); const [airwayBillPopup, setAirwayBillPopup] = useState(null); @@ -84,8 +86,22 @@ const Transaction = ({ id }) => { }; const [cancelTransaction, setCancelTransaction] = useState(false); + const [continueNoPo, setContinueNoPo] = useState(false); + const [continueTransaction, setContinueTransaction] = useState(false); const openCancelTransaction = () => setCancelTransaction(true); + const openContinueTransaction = () => { + if (!transaction.data?.purchaseOrderFile) { + setContinueTransaction(true); + } else { + checkout(); + } + }; + const ContinueTransaction = () => { + setContinueNoPo(true); + checkoutNoPO(); + }; const closeCancelTransaction = () => setCancelTransaction(false); + const closeContinueTransaction = () => setContinueTransaction(false); const [rejectTransaction, setRejectTransaction] = useState(false); @@ -101,7 +117,6 @@ const Transaction = ({ id }) => { } closeCancelTransaction(); }; - const checkout = async () => { if (!transaction.data?.purchaseOrderFile) { toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); @@ -112,6 +127,63 @@ const Transaction = ({ id }) => { transaction.refetch(); }; + const checkoutNoPO = async () => { + setIsLoading(true); + gtagPurchase( + transaction.data.products, + transaction.data.deliveryAmount, + transaction.data.name + ); + + gtag('event', 'conversion', { + send_to: 'AW-954540379/nDymCL3BhaQYENvClMcD', + value: + transaction.data?.amountTotal + + Math.round(parseInt(transaction.data.deliveryAmount * 1.1) / 1000) * + 1000, + currency: 'IDR', + transaction_id: transaction.data.id, + }); + + for (const product of transaction.data.products) + deleteItemCart({ productId: product.id }); + if (transaction.data?.amountTotal > 0) { + const payment = await axios.post( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${transaction.data.id}` + ); + setIsLoading(false); + window.location.href = payment.data.redirectUrl; + } else { + window.location.href = `${ + process.env.NEXT_PUBLIC_SELF_HOST + }/shop/checkout/success?order_id=${transaction.data.name.replace( + /\//g, + '-' + )}`; + } + + /* const midtrans = async () => { + for (const product of products) deleteItemCart({ productId: product.id }); + if (grandTotal > 0) { + const payment = await axios.post( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${isCheckouted.id}` + ); + setIsLoading(false); + window.location.href = payment.data.redirectUrl; + } else { + window.location.href = `${ + process.env.NEXT_PUBLIC_SELF_HOST + }/shop/checkout/success?order_id=${isCheckouted.name.replace( + /\//g, + '-' + )}`; + } + };*/ + toast.success('Berhasil melanjutkan pesanan'); + transaction.refetch(); + y; + }; + const handleApproval = async () => { await aprpoveApi({ id }); toast.success('Berhasil melanjutkan approval'); @@ -207,6 +279,32 @@ const Transaction = ({ id }) => { return ( transaction.data?.name && ( <> + +
+ Apakah anda yakin melanjutkan tanpa upload PO?{' '} + {transaction.data?.name}? +
+
+ + +
+
{ )} {transaction.data?.status == 'draft' && !auth?.feature?.soApproval && ( - )} @@ -563,7 +664,10 @@ const Transaction = ({ id }) => { )} {transaction.data?.status == 'draft' && !auth?.feature.soApproval && ( - )} @@ -879,7 +983,7 @@ const Transaction = ({ id }) => { - )} + )} {transaction?.data?.productsRejectLine.length > 0 && (
-- cgit v1.2.3 From 2d99c50da37c2e68ed33a4bc20e9b2ff06578bbe Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 7 Nov 2024 15:55:15 +0700 Subject: update code --- src/lib/transaction/components/Transaction.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 777dd771..f64945f5 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -117,11 +117,12 @@ const Transaction = ({ id }) => { } closeCancelTransaction(); }; + console.log('transaction', transaction); const checkout = async () => { - if (!transaction.data?.purchaseOrderFile) { - toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); - return; - } + // if (!transaction.data?.purchaseOrderFile) { + // toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); + // return; + // } await checkoutPoApi({ id }); toast.success('Berhasil melanjutkan pesanan'); transaction.refetch(); @@ -161,6 +162,8 @@ const Transaction = ({ id }) => { '-' )}`; } + toast.success('Berhasil melanjutkan pesanan'); + transaction.refetch(); /* const midtrans = async () => { for (const product of products) deleteItemCart({ productId: product.id }); @@ -179,9 +182,6 @@ const Transaction = ({ id }) => { )}`; } };*/ - toast.success('Berhasil melanjutkan pesanan'); - transaction.refetch(); - y; }; const handleApproval = async () => { -- cgit v1.2.3 From f80551e64e7b4fa1463ecd47d744f7f2846abfda Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 7 Nov 2024 16:49:38 +0700 Subject: update quotation --- src/lib/transaction/api/checkoutPoApi.js | 19 ++++++++++--------- src/lib/transaction/components/Transaction.jsx | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lib/transaction/api/checkoutPoApi.js b/src/lib/transaction/api/checkoutPoApi.js index 04421368..3376e773 100644 --- a/src/lib/transaction/api/checkoutPoApi.js +++ b/src/lib/transaction/api/checkoutPoApi.js @@ -1,13 +1,14 @@ -import odooApi from '@/core/api/odooApi' -import { getAuth } from '@/core/utils/auth' +import odooApi from '@/core/api/odooApi'; +import { getAuth } from '@/core/utils/auth'; -const checkoutPoApi = async ({ id }) => { - const auth = getAuth() +const checkoutPoApi = async ({ id, status }) => { + const auth = getAuth(); const dataCheckout = await odooApi( 'POST', - `/api/v1/partner/${auth?.partnerId}/sale_order/${id}/checkout` - ) - return dataCheckout -} + `/api/v1/partner/${auth?.partnerId}/sale_order/${id}/checkout`, + { status } + ); + return dataCheckout; +}; -export default checkoutPoApi +export default checkoutPoApi; diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index f64945f5..d9edb670 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -123,7 +123,7 @@ const Transaction = ({ id }) => { // toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); // return; // } - await checkoutPoApi({ id }); + await checkoutPoApi({ id, status: true }); toast.success('Berhasil melanjutkan pesanan'); transaction.refetch(); }; -- cgit v1.2.3 From 88198c83806b69ce6ab7815cee5c139536849c9f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 8 Nov 2024 13:55:44 +0700 Subject: update quotation website --- src-migrate/types/auth.ts | 9 +++++---- src/lib/transaction/components/Transaction.jsx | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src-migrate/types/auth.ts b/src-migrate/types/auth.ts index 593e120f..8feac2e1 100644 --- a/src-migrate/types/auth.ts +++ b/src-migrate/types/auth.ts @@ -16,10 +16,11 @@ export type AuthProps = { company: boolean; pricelist: string | null; token: string; - feature : { - onlyReadyStock : boolean, - soApproval : boolean - } + feature: { + onlyReadyStock: boolean; + soApproval: boolean; + }; + partner_tempo: boolean; }; export type AuthApiProps = OdooApiRes; diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index d9edb670..6277e3e0 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -90,16 +90,20 @@ const Transaction = ({ id }) => { const [continueTransaction, setContinueTransaction] = useState(false); const openCancelTransaction = () => setCancelTransaction(true); const openContinueTransaction = () => { - if (!transaction.data?.purchaseOrderFile) { - setContinueTransaction(true); - } else { + if (auth.partnerTempo) { checkout(); + } else { + if (!transaction.data?.purchaseOrderFile) { + setContinueTransaction(true); + } else { + checkoutNoPO(); + } } }; - const ContinueTransaction = () => { - setContinueNoPo(true); - checkoutNoPO(); - }; + // const ContinueTransaction = () => { + // setContinueNoPo(true); + // checkoutNoPO(); + // }; const closeCancelTransaction = () => setCancelTransaction(false); const closeContinueTransaction = () => setContinueTransaction(false); @@ -119,10 +123,10 @@ const Transaction = ({ id }) => { }; console.log('transaction', transaction); const checkout = async () => { - // if (!transaction.data?.purchaseOrderFile) { - // toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); - // return; - // } + if (!transaction.data?.purchaseOrderFile) { + toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); + return; + } await checkoutPoApi({ id, status: true }); toast.success('Berhasil melanjutkan pesanan'); transaction.refetch(); -- cgit v1.2.3 From a1e4d12c041dc8f06de531a9f7f287e07ccc81e8 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 18 Nov 2024 16:54:53 +0700 Subject: delete categories --- src/pages/index.jsx | 237 +++++++++++++++++++++++++--------------------------- 1 file changed, 113 insertions(+), 124 deletions(-) diff --git a/src/pages/index.jsx b/src/pages/index.jsx index cc4d68db..2ec1231a 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -45,18 +45,19 @@ const FlashSale = dynamic( } ); -const ProgramPromotion = dynamic(() => - import('@/lib/home/components/PromotionProgram'), -{ - loading: () => , -} +const ProgramPromotion = dynamic( + () => import('@/lib/home/components/PromotionProgram'), + { + loading: () => , + } ); const BannerSection = dynamic(() => import('@/lib/home/components/BannerSection') -); -const CategoryHomeId = dynamic(() => - import('@/lib/home/components/CategoryHomeId'), {ssr: false} +); +const CategoryHomeId = dynamic( + () => import('@/lib/home/components/CategoryHomeId'), + { ssr: false } ); const CategoryDynamic = dynamic(() => @@ -64,17 +65,18 @@ const CategoryDynamic = dynamic(() => ); const CategoryDynamicMobile = dynamic(() => -import('@/lib/home/components/CategoryDynamicMobile') + import('@/lib/home/components/CategoryDynamicMobile') ); -const CustomerReviews = dynamic(() => - import('@/lib/review/components/CustomerReviews'), {ssr: false} +const CustomerReviews = dynamic( + () => import('@/lib/review/components/CustomerReviews'), + { ssr: false } ); // need to ssr:false -const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'), {ssr: false}); // need to ssr: false +const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'), { + ssr: false, +}); // need to ssr: false - - -export default function Home({categoryId}) { +export default function Home({ categoryId }) { const bannerRef = useRef(null); const wrapperRef = useRef(null); @@ -85,123 +87,110 @@ 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 ( <> - - - - - - -
-
-
- -
-
- + + + + + + +
+
+
+ +
+
+ +
+
+ + + +
-
- - - -
-
-
- -
- +
+ +
+ +
+ {!auth?.feature?.soApproval && ( + <> + + + + + + + + )} + {/* */} + + + + +
+
+ + + + + +
+ + + + +
+ +
+
{!auth?.feature?.soApproval && ( <> - - - - - - + + + + + + )} - {/* */} - {dataCategories &&( - - )} - - - - + + {/* */} + + + + + + + + + + + + + + +
-
-
- - - - -
- - - - -
- -
-
- {!auth?.feature?.soApproval && ( - <> - - - - - - - - )} - - {/* */} - - - {dataCategories &&( - - )} - - - - - - - - - - - - -
-
-
- + + + ); -} \ No newline at end of file +} -- cgit v1.2.3 From 4d1dd6ad5b22ffb02e4347cf3159f10988fd7c03 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 19 Nov 2024 10:49:07 +0700 Subject: redis v2 --- src/lib/flashSale/components/FlashSale.jsx | 36 +++++++++++++++--------- src/pages/api/flashsale-header.js | 40 ++++++++++++++++++++++++++ src/pages/api/search-flashsale.js | 45 ++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 src/pages/api/flashsale-header.js create mode 100644 src/pages/api/search-flashsale.js diff --git a/src/lib/flashSale/components/FlashSale.jsx b/src/lib/flashSale/components/FlashSale.jsx index 8be1d7a6..6d90cad7 100644 --- a/src/lib/flashSale/components/FlashSale.jsx +++ b/src/lib/flashSale/components/FlashSale.jsx @@ -2,10 +2,8 @@ import Image from 'next/image'; import { useEffect, useState } from 'react'; import CountDown from '@/core/components/elements/CountDown/CountDown'; -import productSearchApi from '@/lib/product/api/productSearchApi'; import ProductSlider from '@/lib/product/components/ProductSlider'; -import flashSaleApi from '../api/flashSaleApi'; import { FlashSaleSkeleton } from '../skeleton/FlashSaleSkeleton'; const FlashSale = () => { @@ -14,10 +12,14 @@ const FlashSale = () => { useEffect(() => { const loadFlashSales = async () => { - const dataFlashSales = await flashSaleApi(); - setFlashSales(dataFlashSales); + const res = await fetch('/api/flashsale-header'); + const { data } = await res.json(); + if (data) { + setFlashSales(data); + } setIsLoading(false); }; + loadFlashSales(); }, []); @@ -53,7 +55,10 @@ const FlashSale = () => { height={48} className='w-full rounded mb-4 block sm:hidden' /> - +
))} @@ -63,19 +68,24 @@ const FlashSale = () => { ); }; -const FlashSaleProduct = ({ flashSaleId }) => { +const FlashSaleProduct = ({ flashSaleId, duration }) => { const [products, setProducts] = useState(null); - useEffect(() => { + const data_search = new URLSearchParams({ + query: `fq=flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale-price-asc&source=similar`, + operation: 'AND', + duration: `${duration}`, + }); const loadProducts = async () => { - const dataProducts = await productSearchApi({ - query: `fq=flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale-price-asc&source=similar`, - operation: 'AND', - }); - setProducts(dataProducts.response); + const res = await fetch( + `/api/search-flashsale?${data_search.toString()}` + ); + const { data } = await res.json(); + setProducts(data.response); }; + loadProducts(); - }, [flashSaleId]); + }, []); return ; }; diff --git a/src/pages/api/flashsale-header.js b/src/pages/api/flashsale-header.js new file mode 100644 index 00000000..31f8efdd --- /dev/null +++ b/src/pages/api/flashsale-header.js @@ -0,0 +1,40 @@ +import odooApi from '@/core/api/odooApi'; +import { createClient } from 'redis'; + +const client = createClient(); + +client.on('error', (err) => console.error('Redis Client Error', err)); + +const connectRedis = async () => { + if (!client.isOpen) { + await client.connect(); + } +}; + +export default async function handler(req, res) { + try { + await connectRedis(); + const cacheKey = `flashsale_header`; + // await client.del(cacheKey); + let cachedData = await client.get(cacheKey); + + if (cachedData) { + const data = JSON.parse(cachedData); + return res.status(200).json({ data }); + } else { + const flashSale = await odooApi('GET', `/api/v1/flashsale/header`); + + await client.set( + cacheKey, + JSON.stringify(flashSale), + 'EX', + flashSale.duration + ); + cachedData = await client.get(cacheKey); + return res.status(200).json({ data: cachedData }); + } + } catch (error) { + console.error('Error interacting with Redis or fetching data:', error); + return res.status(500).json({ error: 'Internal Server Error' }); + } +} diff --git a/src/pages/api/search-flashsale.js b/src/pages/api/search-flashsale.js new file mode 100644 index 00000000..d9e56c83 --- /dev/null +++ b/src/pages/api/search-flashsale.js @@ -0,0 +1,45 @@ +import odooApi from '@/core/api/odooApi'; +import { createClient } from 'redis'; +import _ from 'lodash-contrib'; +import axios from 'axios'; + +const client = createClient(); + +client.on('error', (err) => console.error('Redis Client Error', err)); + +const connectRedis = async () => { + if (!client.isOpen) { + await client.connect(); + } +}; + +export default async function handler(req, res) { + const { query, operation, duration } = req.query; + try { + await connectRedis(); + const cacheKey = `flashsale_product`; + // await client.del(cacheKey); + let cachedData = await client.get(cacheKey); + + if (cachedData) { + const data = JSON.parse(cachedData); + return res.status(200).json({ data }); + } else { + const dataProductSearch = await axios( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?${query}&operation=${operation}]` + ); + + await client.set( + cacheKey, + JSON.stringify(dataProductSearch.data), + 'EX', + duration + ); + cachedData = await client.get(cacheKey); + return res.status(200).json({ data: cachedData }); + } + } catch (error) { + console.error('Error interacting with Redis or fetching data:', error); + return res.status(500).json({ error: 'Internal Server Error' }); + } +} -- cgit v1.2.3 From 9f10b502da7e1d102ddb0b16175b828834ff6f44 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 19 Nov 2024 10:50:07 +0700 Subject: delete console log --- src-migrate/pages/shop/cart/index.tsx | 2 -- src/pages/api/page-content.js | 1 - src/pages/api/shop/search.js | 9 +-------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index 70a28073..24baa933 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -35,8 +35,6 @@ const CartPage = () => { const [hasChanged, setHasChanged] = useState(false); const prevCartRef = useRef(null); - console.log('ini cart', cart); - useEffect(() => { const handleScroll = () => { setIsTop(window.scrollY < 200); diff --git a/src/pages/api/page-content.js b/src/pages/api/page-content.js index 3cb8a237..a6514505 100644 --- a/src/pages/api/page-content.js +++ b/src/pages/api/page-content.js @@ -22,7 +22,6 @@ export default async function handler(req, res) { if (!cachedData) { const items = await getPageContent({ path }); - console.log('items', items); await client.set( `page-content:${path}`, JSON.stringify(items), diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 65927bbc..63ec7ca0 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -19,12 +19,7 @@ export default async function handler(req, res) { source = '', } = req.query; - - - console.log('fq new', fq); - let { stock = '' } = req.query; - let paramOrderBy = ''; switch (orderBy) { case 'flashsale-discount-desc': @@ -93,7 +88,6 @@ export default async function handler(req, res) { 'price_tier1_v2_f:[1 TO *]', ]; - if (fq && source != 'similar' && typeof fq != 'string') { // filterQueries.push(fq); fq.push(...filterQueries); @@ -103,7 +97,7 @@ export default async function handler(req, res) { let keywords = newQ; if (source === 'similar' || checkQ.length < 3) { if (checkQ.length < 2 || checkQ[1].length < 2) { - keywords = newQ ; + keywords = newQ; } else { keywords = newQ + '*'; } @@ -170,7 +164,6 @@ export default async function handler(req, res) { parameter = parameter.concat( fq.map((val) => `fq=${encodeURIComponent(val)}`) ); - let result = await axios( process.env.SOLR_HOST + '/solr/product/select?' + parameter.join('&') ); -- cgit v1.2.3 From 867bbe11bf98297177d999fa4a8c69054d2ec72d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 19 Nov 2024 17:29:59 +0700 Subject: bug shipnent --- src/lib/treckingAwb/component/Manifest.jsx | 124 ++++++++++++++++------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx index fbc95702..02d0bc7a 100644 --- a/src/lib/treckingAwb/component/Manifest.jsx +++ b/src/lib/treckingAwb/component/Manifest.jsx @@ -1,16 +1,16 @@ -import odooApi from '@/core/api/odooApi' -import BottomPopup from '@/core/components/elements/Popup/BottomPopup' -import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' -import { getAuth } from '@/core/utils/auth' -import { useEffect, useState } from 'react' -import { toast } from 'react-hot-toast' -import ImageNext from 'next/image' -import { list } from 'postcss' +import odooApi from '@/core/api/odooApi'; +import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'; +import { getAuth } from '@/core/utils/auth'; +import { useEffect, useState } from 'react'; +import { toast } from 'react-hot-toast'; +import ImageNext from 'next/image'; +import { list } from 'postcss'; const Manifest = ({ idAWB, closePopup }) => { - const [manifests, setManifests] = useState(null) - const [isLoading, setIsLoading] = useState(false) - + const [manifests, setManifests] = useState(null); + const [isLoading, setIsLoading] = useState(false); + console.log('manifests', manifests); const formatCustomDate = (date) => { const months = [ 'Jan', @@ -24,61 +24,60 @@ const Manifest = ({ idAWB, closePopup }) => { 'Sep', 'Oct', 'Nov', - 'Dec' - ] + 'Dec', + ]; - const parts = date.split(' ') // Pisahkan tanggal dan waktu - const [datePart, timePart] = parts - const [yyyy, mm, dd] = datePart.split('-') - const [hh, min] = timePart.split(':') + const parts = date.split(' '); // Pisahkan tanggal dan waktu + const [datePart, timePart] = parts; + const [yyyy, mm, dd] = datePart.split('-'); + const [hh, min] = timePart.split(':'); - const monthAbbreviation = months[parseInt(mm, 10) - 1] + const monthAbbreviation = months[parseInt(mm, 10) - 1]; - return `${dd} ${monthAbbreviation} ${hh}:${min}` - } + return `${dd} ${monthAbbreviation} ${hh}:${min}`; + }; const getManifest = async () => { - setIsLoading(true) - const auth = getAuth() - let list - if(auth){ + setIsLoading(true); + const auth = getAuth(); + let list; + if (auth) { list = await odooApi( 'GET', `/api/v1/partner/${auth.partnerId}/stock-picking/${idAWB}/tracking` - ) - }else{ - list = await odooApi( - 'GET', - `/api/v1/stock-picking/${idAWB}/tracking` - ) + ); + } else { + list = await odooApi('GET', `/api/v1/stock-picking/${idAWB}/tracking`); } - setManifests(list) - setIsLoading(false) - } + setManifests(list); + setIsLoading(false); + }; useEffect(() => { if (idAWB) { - getManifest() + getManifest(); } else { - setManifests(null) + setManifests(null); } - }, [idAWB]) + }, [idAWB]); - const [copied, setCopied] = useState(false) + const [copied, setCopied] = useState(false); const handleCopyClick = () => { - const textToCopy = manifests?.waybillNumber - navigator.clipboard.writeText(textToCopy) - setCopied(true) - toast.success('No Resi Berhasil di Copy') - setTimeout(() => setCopied(false), 2000) // Reset copied state after 2 seconds - } + const textToCopy = manifests?.waybillNumber; + navigator.clipboard.writeText(textToCopy); + setCopied(true); + toast.success('No Resi Berhasil di Copy'); + setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds + }; return ( <> {isLoading && ( -
Mohon Tunggu
+
+ Mohon Tunggu +
@@ -111,11 +110,14 @@ const Manifest = ({ idAWB, closePopup }) => {

- Estimasi tiba pada ({manifests?.eta}) + Estimasi tiba pada{' '} + ({manifests?.eta})

Dikirim Menggunakan{' '} - {manifests?.deliveryOrder.carrier} + + {manifests?.deliveryOrder.carrier} +

{manifests?.waybillNumber && (
@@ -154,10 +156,16 @@ const Manifest = ({ idAWB, closePopup }) => { {manifests.delivered == true && index == 0 ? (
- +
) : (
{ {manifests.delivered != true && (
)} @@ -176,9 +186,15 @@ const Manifest = ({ idAWB, closePopup }) => { {formatCustomDate(manifest.datetime)} {manifests.delivered == true && index == 0 && ( -

Sudah Sampai

+

+ Sudah Sampai +

)} -

{manifest.description}

+

+ {manifest.description} +

))} @@ -187,7 +203,7 @@ const Manifest = ({ idAWB, closePopup }) => { )} - ) -} + ); +}; -export default Manifest +export default Manifest; -- cgit v1.2.3 From 4ad0a71a100f4a5f7893b778705c4a67ba29ceeb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 20 Nov 2024 09:07:01 +0700 Subject: handle no image brand --- .../product-detail/components/Information.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src-migrate/modules/product-detail/components/Information.tsx b/src-migrate/modules/product-detail/components/Information.tsx index b9f4be91..2c23f25e 100644 --- a/src-migrate/modules/product-detail/components/Information.tsx +++ b/src-migrate/modules/product-detail/components/Information.tsx @@ -190,13 +190,19 @@ const Information = ({ product }: Props) => { product.manufacture.id.toString() )} > - {product.manufacture.name} + {product?.manufacture.logo ? ( + {product.manufacture.name} + ) : ( +

+ {product.manufacture.name} +

+ )} ) : ( '-' -- cgit v1.2.3 From d1c09d1cb96808ff144575c6e01535948eb8f8d4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 20 Nov 2024 10:45:43 +0700 Subject: add price action mengambang di product mobile variant --- .../components/Product/ProductMobileVariant.jsx | 154 ++++++++++----------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index b87bcbc8..de5c3f10 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -168,44 +168,14 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { return ( - {product.name} - -
-
- {product.manufacture?.name ? ( - - {product.manufacture?.name} - - ) : ( -
-
- )} - -
-

- {activeVariant?.name} -

- +
{activeVariant.isFlashSale && activeVariant?.price?.discountPercentage > 0 ? ( <>
-
+
{activeVariant?.price?.discountPercentage}%
@@ -223,7 +193,7 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => {
) : ( -

+
{activeVariant?.price?.price > 0 ? ( <> {currencyFormat(activeVariant?.price?.price)} @@ -253,54 +223,84 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { )} -

+
)} +
+
Jumlah
+
+
+ setQuantity(e.target.value)} + /> +
+ + +
+ +
- - + {product.name}
-
Jumlah
-
-
- setQuantity(e.target.value)} - /> -
- -
- +

+ {activeVariant?.name} +

-- cgit v1.2.3 From cbd9bc991a572a80a840a8105640a1b0f1a8bdd4 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Wed, 20 Nov 2024 10:50:39 +0700 Subject: bugs fix filter variant price != 0 --- src/pages/api/shop/product-detail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 247f2a04..faa96028 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -8,7 +8,7 @@ export default async function handler(req, res) { ) 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` + `/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) -- cgit v1.2.3 From e2a12aa22089349cb48511d0584991b9db64e0ca Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Wed, 20 Nov 2024 11:09:46 +0700 Subject: udpate variants total --- src-migrate/modules/product-detail/components/Information.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-migrate/modules/product-detail/components/Information.tsx b/src-migrate/modules/product-detail/components/Information.tsx index 2c23f25e..5e1ea186 100644 --- a/src-migrate/modules/product-detail/components/Information.tsx +++ b/src-migrate/modules/product-detail/components/Information.tsx @@ -96,7 +96,7 @@ const Information = ({ product }: Props) => { Date: Thu, 21 Nov 2024 16:58:00 +0700 Subject: update produk ready stock berdasarkan variant --- src-migrate/modules/product-detail/components/PriceAction.tsx | 2 +- src-migrate/types/productVariant.ts | 1 + src/utils/solrMapping.js | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 413c643a..0b27b1b3 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -162,7 +162,7 @@ const PriceAction = ({ product }: Props) => { */}
- {product?.is_in_bu && ( + {selectedVariant?.is_in_bu && ( { name: product.manufacture_name_s || '', imagePromotion1: product.image_promotion_1_s || '', imagePromotion2: product.image_promotion_2_s || '', - logo : product.x_logo_manufacture_s || '', + logo: product.x_logo_manufacture_s || '', }; } @@ -129,13 +129,14 @@ export const variantsMappingSolr = (parent, products, pricelist) => { manufacture: {}, parent: {}, qtySold: product?.qty_sold_f || 0, + is_in_bu: product?.is_in_bu_b || false, }; if (product.manufacture_id_i && product.manufacture_name_s) { productMapped.manufacture = { id: product.manufacture_id_i || '', name: product.manufacture_name_s || '', - logo : parent[0]?.x_logo_manufacture_s + logo: parent[0]?.x_logo_manufacture_s, }; } productMapped.parent = { -- cgit v1.2.3 From 952421c810b53ec4d25ad5ef605bae1bd1d5d616 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 26 Nov 2024 16:07:09 +0700 Subject: update code register to registerTnc --- .../modules/register/components/TermCondition.tsx | 48 ++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src-migrate/modules/register/components/TermCondition.tsx b/src-migrate/modules/register/components/TermCondition.tsx index d54fe921..44275917 100644 --- a/src-migrate/modules/register/components/TermCondition.tsx +++ b/src-migrate/modules/register/components/TermCondition.tsx @@ -1,34 +1,48 @@ -import { Checkbox } from '@chakra-ui/react' -import React from 'react' -import { Modal } from '~/components/ui/modal' -import { useRegisterStore } from "../stores/useRegisterStore"; -import PageContent from '~/modules/page-content' +import { Checkbox } from '@chakra-ui/react'; +import React from 'react'; +import { Modal } from '~/components/ui/modal'; +import { useRegisterStore } from '../stores/useRegisterStore'; + +import dynamic from 'next/dynamic'; +const PageContent = dynamic( + () => import('@/lib/content/components/PageContent') +); const TermCondition = () => { - const { isOpenTNC, closeTNC, isCheckedTNC, toggleCheckTNC, openTNC } = useRegisterStore() + const { isOpenTNC, closeTNC, isCheckedTNC, toggleCheckTNC, openTNC } = + useRegisterStore(); return ( <> -
- +
+
- - {' '} + {' '} syarat dan ketentuan - +
- - + + - ) -} + ); +}; -export default TermCondition \ No newline at end of file +export default TermCondition; -- cgit v1.2.3 From da8350ee1de81d668e117744c3735d848dd53f6e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 29 Nov 2024 10:13:41 +0700 Subject: delete console log --- src/lib/transaction/components/Transaction.jsx | 1 - src/lib/treckingAwb/component/Manifest.jsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index b1e92f1b..63230cb8 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -121,7 +121,6 @@ const Transaction = ({ id }) => { } closeCancelTransaction(); }; - console.log('transaction', transaction); const checkout = async () => { if (!transaction.data?.purchaseOrderFile) { toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan'); diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx index 02d0bc7a..87e01e38 100644 --- a/src/lib/treckingAwb/component/Manifest.jsx +++ b/src/lib/treckingAwb/component/Manifest.jsx @@ -10,7 +10,6 @@ import { list } from 'postcss'; const Manifest = ({ idAWB, closePopup }) => { const [manifests, setManifests] = useState(null); const [isLoading, setIsLoading] = useState(false); - console.log('manifests', manifests); const formatCustomDate = (date) => { const months = [ 'Jan', -- cgit v1.2.3