summaryrefslogtreecommitdiff
path: root/src/lib/quotation/components
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2024-09-26 11:33:58 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2024-09-26 11:33:58 +0700
commit8fe167e2e03efcd3d7058c22f4efc6db961de71f (patch)
tree9734734660e6088cebd1738d8ac161834630937f /src/lib/quotation/components
parentd4cb977d050a54b9daa1658b6de6e82878ca4c9b (diff)
parent1c56a76f979a6e433d70634b92b1887fb1f19509 (diff)
Merge branch 'new-release' into CR/product_detail
# Conflicts: # package.json # src/utils/solrMapping.js
Diffstat (limited to 'src/lib/quotation/components')
-rw-r--r--src/lib/quotation/components/Quotation.jsx107
-rw-r--r--src/lib/quotation/components/Quotationheader.jsx125
2 files changed, 148 insertions, 84 deletions
diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx
index 0ad042de..cf0ad41f 100644
--- a/src/lib/quotation/components/Quotation.jsx
+++ b/src/lib/quotation/components/Quotation.jsx
@@ -39,12 +39,12 @@ const { getProductsCheckout } = require('@/lib/checkout/api/checkoutApi');
const Quotation = () => {
const router = useRouter();
const auth = useAuth();
-
+
const { data: cartCheckout } = useQuery('cartCheckout', () =>
getProductsCheckout()
-);
+ );
-const { setRefreshCart } = useProductCartContext();
+ const { setRefreshCart } = useProductCartContext();
const SELF_PICKUP_ID = 32;
const [products, setProducts] = useState(null);
@@ -69,18 +69,18 @@ const { setRefreshCart } = useProductCartContext();
const [selectedExpedisiService, setselectedExpedisiService] = useState(null);
const [etd, setEtd] = useState(null);
const [etdFix, setEtdFix] = useState(null);
-
+
const [isApproval, setIsApproval] = useState(false);
-
+
const expedisiValidation = useRef(null);
-
+
const [selectedAddress, setSelectedAddress] = useState({
shipping: null,
invoicing: null,
});
-
+
const [addresses, setAddresses] = useState(null);
-
+
const [note_websiteText, setselectedNote_websiteText] = useState('');
useEffect(() => {
@@ -99,6 +99,9 @@ const { setRefreshCart } = useProductCartContext();
if (!addresses) return;
const matchAddress = (key) => {
+ if (key === 'invoicing') {
+ key = 'invoice';
+ }
const addressToMatch = getItemAddress(key);
const foundAddress = addresses.filter(
(address) => address.id == addressToMatch
@@ -271,7 +274,7 @@ const { setRefreshCart } = useProductCartContext();
toast.error('Maaf, Note wajib dimasukkan.');
return;
}
-
+
setIsLoading(true);
const productOrder = products.map((product) => ({
product_id: product.id,
@@ -286,11 +289,10 @@ const { setRefreshCart } = useProductCartContext();
carrier_id: selectedCarrierId,
estimated_arrival_days: splitDuration(etd),
delivery_service_type: selectedExpedisiService,
- note_website : note_websiteText,
+ note_website: note_websiteText,
};
-
+
const isSuccess = await checkoutApi({ data });
- ;
setIsLoading(false);
if (isSuccess?.id) {
for (const product of products) deleteItemCart({ productId: product.id });
@@ -298,7 +300,7 @@ const { setRefreshCart } = useProductCartContext();
setRefreshCart(true);
return;
}
-
+
toast.error('Gagal melakukan transaksi, terjadi kesalahan internal');
};
@@ -455,25 +457,26 @@ const { setRefreshCart } = useProductCartContext();
</Link>{' '}
yang berlaku
</p>
- <hr className='my-4 border-gray_r-6' />
-
- <div className='flex gap-x-2 justify-start mb-4'>
- <div className=''>Note</div>
- {isApproval && (
- <div className='text-caption-1 text-red-500 items-center flex'>*harus diisi</div>
- )}
- </div>
- <div className='text-caption-2 text-gray_r-11'>
- <textarea
- rows="4"
- cols="50"
- className={`w-full p-1 rounded border border-gray_r-6`}
- onChange={(e) => setselectedNote_websiteText(e.target.value)}
- />
- </div>
+ <hr className='my-4 border-gray_r-6' />
+
+ <div className='flex gap-x-2 justify-start mb-4'>
+ <div className=''>Note</div>
+ {isApproval && (
+ <div className='text-caption-1 text-red-500 items-center flex'>
+ *harus diisi
+ </div>
+ )}
+ </div>
+ <div className='text-caption-2 text-gray_r-11'>
+ <textarea
+ rows='4'
+ cols='50'
+ className={`w-full p-1 rounded border border-gray_r-6`}
+ onChange={(e) => setselectedNote_websiteText(e.target.value)}
+ />
+ </div>
</div>
-
-
+
<Divider />
<div className='flex gap-x-3 p-4'>
@@ -606,27 +609,31 @@ const { setRefreshCart } = useProductCartContext();
yang berlaku
</p>
- <div>
- <hr className='my-4 border-gray_r-6' />
-
- <div className='flex gap-x-1 flex-col mb-4'>
- <div className='flex flex-row gap-x-1'>
- <div className=''>Note</div>
- {isApproval && (
- <div className='text-caption-1 text-red-500 items-center flex'>*harus diisi</div>
- )}
- </div>
- <div className='text-caption-2 text-gray_r-11'>
- <textarea
- rows="4"
- cols="50"
- className={`w-full p-1 rounded border border-gray_r-6`}
- onChange={(e) => setselectedNote_websiteText(e.target.value)}
- />
- </div>
+ <div>
+ <hr className='my-4 border-gray_r-6' />
+
+ <div className='flex gap-x-1 flex-col mb-4'>
+ <div className='flex flex-row gap-x-1'>
+ <div className=''>Note</div>
+ {isApproval && (
+ <div className='text-caption-1 text-red-500 items-center flex'>
+ *harus diisi
+ </div>
+ )}
+ </div>
+ <div className='text-caption-2 text-gray_r-11'>
+ <textarea
+ rows='4'
+ cols='50'
+ className={`w-full p-1 rounded border border-gray_r-6`}
+ onChange={(e) =>
+ setselectedNote_websiteText(e.target.value)
+ }
+ />
</div>
</div>
-
+ </div>
+
<hr className='my-4 border-gray_r-6' />
<button
diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 4529c977..d94a55de 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);
@@ -53,30 +61,36 @@ const Quotationheader = (quotationCount) => {
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 +109,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 +167,9 @@ const Quotationheader = (quotationCount) => {
className='w-full max-w-md p-2 bg-white border border-gray-200 rounded-lg shadow overflow-hidden'
>
<div className='p-2 flex justify-between items-center'>
- <h5 className='text-base font-semibold leading-none'>Daftar Quotation</h5>
+ <h5 className='text-base font-semibold leading-none'>
+ Daftar Quotation
+ </h5>
</div>
<hr className='mt-3 mb-3 border border-gray-100' />
<div className='flow-root max-h-[250px] overflow-y-auto'>
@@ -158,7 +177,10 @@ const Quotationheader = (quotationCount) => {
<div className='justify-center p-4'>
<p className='text-gray-500 text-center '>
Silahkan{' '}
- <Link href='/login' className='text-red-600 underline leading-6'>
+ <Link
+ href='/login'
+ className='text-red-600 underline leading-6'
+ >
Login
</Link>{' '}
Untuk Melihat Daftar Quotation Anda
@@ -167,7 +189,11 @@ const Quotationheader = (quotationCount) => {
)}
{isLoading &&
itemLoading.map((item) => (
- <div key={item} role='status' className='max-w-sm animate-pulse'>
+ <div
+ key={item}
+ role='status'
+ className='max-w-sm animate-pulse'
+ >
<div className='flex items-center space-x-4 mb- 2'>
<div className='flex-shrink-0'>
<PhotoIcon className='h-16 w-16 text-gray-500' />
@@ -189,43 +215,70 @@ const Quotationheader = (quotationCount) => {
)}
{auth && qotation.length > 0 && !isLoading && (
<>
- <ul role='list' className='divide-y divide-gray-200 dark:divide-gray-700'>
+ <ul
+ role='list'
+ className='divide-y divide-gray-200 dark:divide-gray-700'
+ >
{qotation &&
qotation?.map((product, index) => (
<>
<li className='py-1 sm:py-2'>
<div className='flex justify-between border p-2 flex-col gap-y-2 hover:border-red-500'>
- <Link
+ <Link
href={`/my/quotations/${product?.id}`}
- className='hover:border-red-500'
- >
+ className='hover:border-red-500'
+ >
<div className='flex justify-between mb-2'>
<div className='flex flex-row items-center'>
- <p className='tanggal text-xs opacity-80 mr-[2px]'>Sales : </p>
- <p className='tanggal text-xs text-red-500 font-semibold'>{product.sales}</p>
+ <p className='tanggal text-xs opacity-80 mr-[2px]'>
+ Sales :{' '}
+ </p>
+ <p className='tanggal text-xs text-red-500 font-semibold'>
+ {product.sales}
+ </p>
</div>
<div className='flex flex-row items-center'>
- <p className='text-xs opacity-80 mr-[2px]'>Status :</p>
- <p className='badge-red h-fit text-xs whitespace-nowrap'>Pending Quotation</p>
+ <p className='text-xs opacity-80 mr-[2px]'>
+ Status :
+ </p>
+ <p className='badge-red h-fit text-xs whitespace-nowrap'>
+ Pending Quotation
+ </p>
</div>
</div>
<div className='flex justify-between mb-2'>
<div className='flex flex-col items-start'>
- <p className=' text-xs opacity-80 mr-[2px]'>No. Transaksi</p>
- <p className=' text-sm text-red-500 font-semibold'> {product.name}</p>
+ <p className=' text-xs opacity-80 mr-[2px]'>
+ No. Transaksi
+ </p>
+ <p className=' text-sm text-red-500 font-semibold'>
+ {' '}
+ {product.name}
+ </p>
</div>
<div className='flex flex-col items-end'>
- <p className='text-xs opacity-80 mr-[2px]'>No. Purchase Order</p>
- <p className='font-semibold text-sm text-red-500'> {product.purchaseOrderName ? product.purchaseOrderName : '-'}</p>
+ <p className='text-xs opacity-80 mr-[2px]'>
+ No. Purchase Order
+ </p>
+ <p className='font-semibold text-sm text-red-500'>
+ {' '}
+ {product.purchaseOrderName
+ ? product.purchaseOrderName
+ : '-'}
+ </p>
</div>
</div>
{/* <div className='my-0.5 h-0.5 bg-gray-200'></div> */}
<hr className='mt-3 mb-3 border border-gray-100' />
<div className='bagian bawah flex justify-between mt-2'>
- <p className='font-semibold text-sm'>Total</p>
- <p className='font-semibold text-sm'>{currencyFormat(product.amountUntaxed)}</p>
+ <p className='font-semibold text-sm'>
+ Total
+ </p>
+ <p className='font-semibold text-sm'>
+ {currencyFormat(product.amountUntaxed)}
+ </p>
</div>
- </Link>
+ </Link>
</div>
</li>
</>
@@ -238,8 +291,12 @@ const Quotationheader = (quotationCount) => {
{auth && qotation.length > 0 && !isLoading && (
<>
<div className='mt-3 ml-1'>
- <span className='text-gray-400 text-caption-2'>Subtotal Sebelum PPN : </span>
- <span className='font-semibold text-red-600'>{currencyFormat(subTotal)}</span>
+ <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