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(-) (limited to 'src/lib') 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(-) (limited to 'src/lib') 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(-) (limited to 'src/lib') 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/lib/transaction/components/Transaction.jsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/lib') 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 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 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/lib') 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 ; }; -- 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(-) (limited to 'src/lib') 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 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(-) (limited to 'src/lib') 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 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(-) (limited to 'src/lib') 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