summaryrefslogtreecommitdiff
path: root/src/lib/checkout/utils
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-01-28 09:46:11 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-01-28 09:46:11 +0700
commitc26a0d026886e6f70ea3487b9d83a54d20b9c1e4 (patch)
tree2c633d36d5700a6fd61a18f0e292ddce04039849 /src/lib/checkout/utils
parent00afe24409bf3cd517597e7c59cf1c12535c54c0 (diff)
biteship
Diffstat (limited to 'src/lib/checkout/utils')
-rw-r--r--src/lib/checkout/utils/functionCheckouit.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/lib/checkout/utils/functionCheckouit.js b/src/lib/checkout/utils/functionCheckouit.js
index b299f289..a6e6c337 100644
--- a/src/lib/checkout/utils/functionCheckouit.js
+++ b/src/lib/checkout/utils/functionCheckouit.js
@@ -1,17 +1,27 @@
+import { m } from 'framer-motion';
+import { min } from 'moment/moment';
+
export function formatShipmentRange(
shipmentDurationRange,
- shipmentDurationUnit
+ shipmentDurationUnit,
+ productSLA
) {
if (!shipmentDurationRange || !shipmentDurationUnit) {
return '';
}
let minRange, maxRange;
+ console.log('ini masuk', shipmentDurationRange);
+
// Cek apakah durasi berupa range atau angka tunggal
if (shipmentDurationRange.includes('-')) {
[minRange, maxRange] = shipmentDurationRange.split(' - ').map(Number);
+ // if (minRange === maxRange) {
+ // maxRange = minRange + 3;
+ // }
} else {
- minRange = maxRange = Number(shipmentDurationRange); // Jika angka tunggal
+ minRange = Number(shipmentDurationRange); // Jika angka tunggal
+ maxRange = Number(shipmentDurationRange) + 3;
}
const start = new Date(); // Tanggal saat ini
@@ -21,19 +31,22 @@ export function formatShipmentRange(
// Hitung estimasi berdasarkan unit waktu
if (shipmentDurationUnit === 'days' || shipmentDurationUnit === 'day') {
minDate = new Date(start);
- minDate.setDate(start.getDate() + (minRange + 3));
+ minDate.setDate(start.getDate() + (minRange + productSLA));
maxDate = new Date(start);
- maxDate.setDate(start.getDate() + (maxRange + 3));
+ maxDate.setDate(start.getDate() + (maxRange + productSLA));
} else if (shipmentDurationUnit === 'hours') {
- minDate = new Date(start.getTime() + (minRange + 3) * 60 * 60 * 1000);
- maxDate = new Date(start.getTime() + (maxRange + 3) * 60 * 60 * 1000);
+ minDate = new Date(start);
+ minDate.setDate(start.getDate() + (1 + productSLA));
+
+ maxDate = new Date(start);
+ maxDate.setDate(start.getDate() + (1 + productSLA + 1));
+ // minDate = new Date(start.getTime() + (minRange + 3) * 60 * 60 * 1000);
+ // maxDate = new Date(start.getTime() + (maxRange + 3) * 60 * 60 * 1000);
} else {
throw new Error("Unsupported unit. Please use 'days' or 'hours'.");
}
- console.log('min max', minDate, maxDate);
-
const minDateStr = formatDate(minDate);
const maxDateStr = formatDate(maxDate);
if (minDateStr === maxDateStr) {
@@ -60,7 +73,7 @@ export function getToDate(shipmentDurationRange, shipmentDurationUnit) {
let maxDate;
// Hitung estimasi berdasarkan unit waktu
- if (shipmentDurationUnit === 'days' || shipmentDurationUnit === 'day') {
+ if (shipmentDurationUnit === 'days' || shipmentDurationUnit === 'day') {
maxDate = new Date(start);
maxDate.setDate(start.getDate() + (maxRange + 3));
} else if (shipmentDurationUnit === 'hours') {