From 36601aba6017aeef16f89351eb487238402ab52e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 24 Sep 2024 16:12:50 +0700 Subject: update Perapihan Tag --- src/lib/quotation/components/Quotationheader.jsx | 131 +++++++++++++++++------ 1 file changed, 96 insertions(+), 35 deletions(-) (limited to 'src/lib/quotation') diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx index 4529c977..cb7684ed 100644 --- a/src/lib/quotation/components/Quotationheader.jsx +++ b/src/lib/quotation/components/Quotationheader.jsx @@ -19,14 +19,22 @@ const Quotationheader = (quotationCount) => { context: 'quotation', site: auth?.webRole === null && auth?.site ? auth.site : null, }; - + const router = useRouter(); const [subTotal, setSubTotal] = useState(null); const [buttonLoading, SetButtonTerapkan] = useState(false); const itemLoading = [1, 2, 3]; const [countQuotation, setCountQuotation] = useState(null); - const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation } = - useProductCartContext(); + const { + productCart, + setProductCart, + refreshCart, + setRefreshCart, + isLoading, + setIsloading, + productQuotation, + setProductQuotation, + } = useProductCartContext(); const [isHovered, setIsHovered] = useState(false); const [isTop, setIsTop] = useState(true); @@ -49,34 +57,44 @@ const Quotationheader = (quotationCount) => { refreshCartf(); } }; - let { transactions } = useTransactions({ query }); + let transactions = null; + + if (auth) { + transactions = useTransactions({ query }); + } const refreshCartf = useCallback(async () => { setIsloading(true); - let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft'); + let pendingTransactions = transactions?.data?.saleOrders.filter( + (transaction) => transaction.status === 'draft' + ); setProductQuotation(pendingTransactions); - setCountQuotation(pendingTransactions?.length ? pendingTransactions?.length : pendingTransactions?.length); + setCountQuotation( + pendingTransactions?.length + ? pendingTransactions?.length + : pendingTransactions?.length + ); setIsloading(false); }, [setProductQuotation, setIsloading]); useEffect(() => { - if (!qotation) return + if (!qotation) return; - let calculateTotalDiscountAmount = 0 + let calculateTotalDiscountAmount = 0; for (const product of qotation) { - // if (qotation.quantity == '') continue - calculateTotalDiscountAmount += product.amountUntaxed + // if (qotation.quantity == '') continue + calculateTotalDiscountAmount += product.amountUntaxed; } - let subTotal = calculateTotalDiscountAmount - setSubTotal(subTotal) - }, [qotation]) + let subTotal = calculateTotalDiscountAmount; + setSubTotal(subTotal); + }, [qotation]); useEffect(() => { if (refreshCart) { refreshCartf(); } setRefreshCart(false); - }, [ refreshCartf, setRefreshCart]); + }, [refreshCartf, setRefreshCart]); useEffect(() => { setCountQuotation(quotationCount.quotationCount); @@ -95,7 +113,10 @@ const Quotationheader = (quotationCount) => { const handleCheckout = async () => { SetButtonTerapkan(true); - let checkoutAll = await odooApi('POST', `/api/v1/user/${auth.id}/cart/select-all`); + let checkoutAll = await odooApi( + 'POST', + `/api/v1/user/${auth.id}/cart/select-all` + ); router.push('/my/quotations'); }; @@ -150,7 +171,9 @@ const Quotationheader = (quotationCount) => { className='w-full max-w-md p-2 bg-white border border-gray-200 rounded-lg shadow overflow-hidden' >
-
Daftar Quotation
+
+ Daftar Quotation +

@@ -158,7 +181,10 @@ const Quotationheader = (quotationCount) => {

Silahkan{' '} - + Login {' '} Untuk Melihat Daftar Quotation Anda @@ -167,7 +193,11 @@ const Quotationheader = (quotationCount) => { )} {isLoading && itemLoading.map((item) => ( -

+
@@ -189,43 +219,70 @@ const Quotationheader = (quotationCount) => { )} {auth && qotation.length > 0 && !isLoading && ( <> -
    +
      {qotation && qotation?.map((product, index) => ( <>
    • - + className='hover:border-red-500' + >
      -

      Sales :

      -

      {product.sales}

      +

      + Sales :{' '} +

      +

      + {product.sales} +

      -

      Status :

      -

      Pending Quotation

      +

      + Status : +

      +

      + Pending Quotation +

      -

      No. Transaksi

      -

      {product.name}

      +

      + No. Transaksi +

      +

      + {' '} + {product.name} +

      -

      No. Purchase Order

      -

      {product.purchaseOrderName ? product.purchaseOrderName : '-'}

      +

      + No. Purchase Order +

      +

      + {' '} + {product.purchaseOrderName + ? product.purchaseOrderName + : '-'} +

      {/*
      */}
      -

      Total

      -

      {currencyFormat(product.amountUntaxed)}

      +

      + Total +

      +

      + {currencyFormat(product.amountUntaxed)} +

      - +
    • @@ -238,8 +295,12 @@ const Quotationheader = (quotationCount) => { {auth && qotation.length > 0 && !isLoading && ( <>
      - Subtotal Sebelum PPN : - {currencyFormat(subTotal)} + + Subtotal Sebelum PPN :{' '} + + + {currencyFormat(subTotal)} +