From a63b03fffdf46ecddecf356d1d00d6582add75cf Mon Sep 17 00:00:00 2001
From: it-fixcomart
Date: Tue, 6 Aug 2024 17:05:01 +0700
Subject: update cart pop up
---
src/lib/quotation/components/Quotationheader.jsx | 67 +++++++++++++++++++-----
1 file changed, 55 insertions(+), 12 deletions(-)
(limited to 'src/lib/quotation/components')
diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 141b731e..9f0f17a6 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -1,16 +1,15 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
-import { getQuotationApi } from '../api/QuotationApi';
-import currencyFormat from '@/core/utils/currencyFormat';
import { createSlug } from '@/core/utils/slug';
import useAuth from '@/core/hooks/useAuth';
import { useRouter } from 'next/router';
import odooApi from '@/core/api/odooApi';
-import { useProductQuotationContext } from '@/contexts/ProductQuotationContext';
+import { useProductCartContext } from '@/contexts/ProductCartContext';
import Image from '@/core/components/elements/Image/Image';
import whatsappUrl from '@/core/utils/whatsappUrl';
import { AnimatePresence, motion } from 'framer-motion';
import style from '../../../../src-migrate/modules/cart/styles/item-promo.module.css';
import useTransactions from '../../transaction/hooks/useTransactions';
+import currencyFormat from '@/core/utils/currencyFormat';
const { DocumentCheckIcon, PhotoIcon } = require('@heroicons/react/24/outline');
const { default: Link } = require('next/link');
@@ -20,14 +19,14 @@ 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 { productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation, isLoading, setIsloading } =
- useProductQuotationContext();
+ const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation } =
+ useProductCartContext();
const [isHovered, setIsHovered] = useState(false);
const [isTop, setIsTop] = useState(true);
@@ -49,12 +48,12 @@ const Quotationheader = (quotationCount) => {
refreshCartf();
}
};
+ let { transactions } = useTransactions({ query });
const refreshCartf = useCallback(async () => {
setIsloading(true);
- let { transactions } = await useTransactions({ query });
let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
setProductQuotation(pendingTransactions);
- setCountQuotation(pendingTransactions.length);
+ setCountQuotation(pendingTransactions?.length ? pendingTransactions?.length : pendingTransactions?.length);
setIsloading(false);
}, [setProductQuotation, setIsloading]);
@@ -66,7 +65,7 @@ const Quotationheader = (quotationCount) => {
}, [refreshQuotation, refreshCartf, setRefreshQuotation]);
useEffect(() => {
- setCountQuotation(quotationCount.cartCount);
+ setCountQuotation(quotationCount.quotationCount);
}, [quotationCount]);
useEffect(() => {
@@ -85,6 +84,8 @@ const Quotationheader = (quotationCount) => {
router.push('/shop/quotation');
};
+ console.log("quotation",qotation)
+
return (
@@ -105,7 +106,7 @@ const Quotationheader = (quotationCount) => {
)}
- Daftar
+ List
Quotation
@@ -137,7 +138,7 @@ const Quotationheader = (quotationCount) => {
>
Daftar Quotation
-
+
Lihat Semua
@@ -150,7 +151,7 @@ const Quotationheader = (quotationCount) => {
Login
{' '}
- Untuk Melihat Daftar Keranjang Belanja Anda
+ Untuk Melihat Daftar Quotation Anda
)}
@@ -176,6 +177,48 @@ const Quotationheader = (quotationCount) => {
)}
+ {auth && qotation.length > 0 && !isLoading && (
+ <>
+
+ {qotation &&
+ qotation?.map((product, index) => (
+ <>
+
+
+
+
{product.dateOrder}
+
Pending Quotation
+
+
+
+
+ No. Transaksi
+
+
+ {product.name}
+
+
+
+
+ No. Purchase Order
+
+
+ {product.purchaseOrderFile}
+
+
+
+
+
Total
+
{currencyFormat(product.amountTotal)}
+
+
+
+ >
+ ))}
+
+
+ >
+ )}
--
cgit v1.2.3