summaryrefslogtreecommitdiff
path: root/src/lib/quotation
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-09-26 03:32:13 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-09-26 03:32:13 +0000
commit1c56a76f979a6e433d70634b92b1887fb1f19509 (patch)
tree046a1a70eb9b53a0a74c951d011715e27220c960 /src/lib/quotation
parent21a7d1e4aaa0ac58fd6d5dbb2942fcf91238e9c4 (diff)
parent0cf4e527dd7565261349d9485a82695379427892 (diff)
Merged in bug/quotation (pull request #335)
<iman> bug ga bisa pilih alamat di quotation
Diffstat (limited to 'src/lib/quotation')
-rw-r--r--src/lib/quotation/components/Quotation.jsx107
1 files changed, 57 insertions, 50 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