Make ETA and pricing more realistic
All checks were successful
Build Docker Image / build (push) Successful in 4m36s
All checks were successful
Build Docker Image / build (push) Successful in 4m36s
This commit is contained in:
@@ -140,19 +140,10 @@ const formatDistance = (km?: number | null) => {
|
|||||||
return t('catalogOfferCard.labels.distance_km', { km: formatted })
|
return t('catalogOfferCard.labels.distance_km', { km: formatted })
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatDuration = (seconds?: number | null) => {
|
const formatDurationDays = (days?: number | null) => {
|
||||||
if (!seconds) return null
|
if (!days) return null
|
||||||
const hours = Math.floor(seconds / 3600)
|
const rounded = Math.max(1, Math.ceil(days))
|
||||||
const minutes = Math.floor((seconds % 3600) / 60)
|
return t('catalogOfferCard.labels.duration_days', { days: rounded })
|
||||||
if (hours >= 24) {
|
|
||||||
const days = Math.floor(hours / 24)
|
|
||||||
const remainingHours = hours % 24
|
|
||||||
return `${days}${t('catalogOfferCard.labels.time_days_short')} ${remainingHours}${t('catalogOfferCard.labels.time_hours_short')}`
|
|
||||||
}
|
|
||||||
if (hours > 0) {
|
|
||||||
return `${hours}${t('catalogOfferCard.labels.time_hours_short')} ${minutes}${t('catalogOfferCard.labels.time_minutes_short')}`
|
|
||||||
}
|
|
||||||
return `${minutes}${t('catalogOfferCard.labels.time_minutes_short')}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTransportIcon = (type?: string | null) => {
|
const getTransportIcon = (type?: string | null) => {
|
||||||
@@ -171,13 +162,26 @@ const getTransportIcon = (type?: string | null) => {
|
|||||||
const getTransportRate = (type?: string | null) => {
|
const getTransportRate = (type?: string | null) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'rail':
|
case 'rail':
|
||||||
return 0.18
|
|
||||||
case 'sea':
|
|
||||||
return 0.12
|
return 0.12
|
||||||
|
case 'sea':
|
||||||
|
return 0.06
|
||||||
case 'road':
|
case 'road':
|
||||||
case 'auto':
|
case 'auto':
|
||||||
default:
|
default:
|
||||||
return 0.35
|
return 0.22
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getTransportSpeedPerDay = (type?: string | null) => {
|
||||||
|
switch (type) {
|
||||||
|
case 'rail':
|
||||||
|
return 900
|
||||||
|
case 'sea':
|
||||||
|
return 800
|
||||||
|
case 'road':
|
||||||
|
case 'auto':
|
||||||
|
default:
|
||||||
|
return 600
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,18 +190,23 @@ const logisticsCost = computed(() => {
|
|||||||
return props.stages.reduce((sum, stage) => {
|
return props.stages.reduce((sum, stage) => {
|
||||||
const km = stage?.distanceKm
|
const km = stage?.distanceKm
|
||||||
if (km == null) return sum
|
if (km == null) return sum
|
||||||
return sum + km * getTransportRate(stage?.transportType)
|
return sum + km * getTransportRate(stage?.transportType) + 40
|
||||||
}, 0)
|
}, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
const totalTimeSeconds = computed(() => {
|
const totalDurationDays = computed(() => {
|
||||||
if (props.totalTimeSeconds != null) return props.totalTimeSeconds
|
|
||||||
if (!props.stages?.length) return null
|
if (!props.stages?.length) return null
|
||||||
const sum = props.stages.reduce((acc, stage) => acc + (stage?.travelTimeSeconds || 0), 0)
|
const stageDays = props.stages.reduce((sum, stage) => {
|
||||||
return sum > 0 ? sum : null
|
const km = stage?.distanceKm
|
||||||
|
if (km == null) return sum
|
||||||
|
return sum + km / getTransportSpeedPerDay(stage?.transportType)
|
||||||
|
}, 0)
|
||||||
|
const transfers = Math.max(0, props.stages.length - 1) * 0.5
|
||||||
|
const buffer = 1
|
||||||
|
return stageDays + transfers + buffer
|
||||||
})
|
})
|
||||||
|
|
||||||
const durationDisplay = computed(() => formatDuration(totalTimeSeconds.value))
|
const durationDisplay = computed(() => formatDurationDays(totalDurationDays.value))
|
||||||
|
|
||||||
const routeRows = computed(() =>
|
const routeRows = computed(() =>
|
||||||
(props.stages || [])
|
(props.stages || [])
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
"unit_kg": "kg",
|
"unit_kg": "kg",
|
||||||
"distance_km": "{km} km",
|
"distance_km": "{km} km",
|
||||||
"duration_label": "ETA",
|
"duration_label": "ETA",
|
||||||
"time_days_short": "d",
|
"duration_days": "{days} d",
|
||||||
"time_hours_short": "h",
|
|
||||||
"time_minutes_short": "m",
|
|
||||||
"country_unknown": "Not specified",
|
"country_unknown": "Not specified",
|
||||||
"supplier_unknown": "Supplier",
|
"supplier_unknown": "Supplier",
|
||||||
"origin_label": "From",
|
"origin_label": "From",
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
"unit_kg": "кг",
|
"unit_kg": "кг",
|
||||||
"distance_km": "{km} км",
|
"distance_km": "{km} км",
|
||||||
"duration_label": "Срок",
|
"duration_label": "Срок",
|
||||||
"time_days_short": "д",
|
"duration_days": "{days} дн",
|
||||||
"time_hours_short": "ч",
|
|
||||||
"time_minutes_short": "м",
|
|
||||||
"country_unknown": "Не указана",
|
"country_unknown": "Не указана",
|
||||||
"supplier_unknown": "Поставщик",
|
"supplier_unknown": "Поставщик",
|
||||||
"origin_label": "Откуда",
|
"origin_label": "Откуда",
|
||||||
|
|||||||
Reference in New Issue
Block a user