diff options
Diffstat (limited to 'src/lib/quotation/components/Quotationheader.jsx')
| -rw-r--r-- | src/lib/quotation/components/Quotationheader.jsx | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx index 79011682..14743fd6 100644 --- a/src/lib/quotation/components/Quotationheader.jsx +++ b/src/lib/quotation/components/Quotationheader.jsx @@ -30,6 +30,7 @@ const Quotationheader = (quotationCount) => { const [isHovered, setIsHovered] = useState(false); const [isTop, setIsTop] = useState(true); + const qotation = useMemo(() => { return productQuotation || []; }, [productQuotation]); @@ -49,6 +50,7 @@ const Quotationheader = (quotationCount) => { } }; let { transactions } = useTransactions({ query }); + const refreshCartf = useCallback(async () => { setIsloading(true); let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft'); @@ -58,6 +60,18 @@ const Quotationheader = (quotationCount) => { }, [setProductQuotation, setIsloading]); useEffect(() => { + if (!qotation) return + + let calculateTotalDiscountAmount = 0 + for (const product of qotation) { + // if (qotation.quantity == '') continue + calculateTotalDiscountAmount += product.amountUntaxed + } + let subTotal = calculateTotalDiscountAmount + setSubTotal(subTotal) + }, [qotation]) + + useEffect(() => { if (refreshQuotation) { refreshCartf(); } @@ -84,8 +98,6 @@ const Quotationheader = (quotationCount) => { router.push('/shop/quotation'); }; - console.log("quotation",qotation) - return ( <div className='relative group'> <div> @@ -211,8 +223,8 @@ const Quotationheader = (quotationCount) => { </div> <div className='my-0.5 h-0.5 bg-gray-200'></div> <div className='bagian bawah flex justify-between mt-2'> - <p className='font-semibold text-base'>Total</p> - <p className='font-semibold text-base'>{currencyFormat(product.amountTotal)}</p> + <p className='font-semibold text-sm'>Total</p> + <p className='font-semibold text-sm'>{currencyFormat(product.amountUntaxed)}</p> </div> </Link> </div> @@ -224,6 +236,24 @@ const Quotationheader = (quotationCount) => { </> )} </div> + {auth && qotation.length > 0 && !isLoading && ( + <> + <div className='mt-3'> + <span className='text-gray-400 text-caption-2'>Subtotal Sebelum PPN : </span> + <span className='font-semibold text-red-600'>{currencyFormat(subTotal)}</span> + </div> + <div className='mt-5 mb-2'> + <button + type='button' + className='btn-yellow rounded-lg w-full' + onClick={handleCheckout} + disabled={buttonLoading} + > + {buttonLoading ? 'Loading...' : 'Buat Quotation'} + </button> + </div> + </> + )} </motion.div> </motion.div> </> |
