diff --git a/apps/frontend/app/[locale]/dashboard/search-advanced/page.tsx b/apps/frontend/app/[locale]/dashboard/search-advanced/page.tsx index 96d127b..50e18bb 100644 --- a/apps/frontend/app/[locale]/dashboard/search-advanced/page.tsx +++ b/apps/frontend/app/[locale]/dashboard/search-advanced/page.tsx @@ -185,14 +185,33 @@ export default function AdvancedSearchPage() { // totals (the booking only stores totals, not individual packages). const q = pallets > 0 ? pallets : 1; const perVolM3 = vol > 0 ? vol / q : 0; - const sideCm = perVolM3 > 0 ? Math.cbrt(perVolM3) * 100 : 0; + const isPalette = pallets > 0; + + // The booking only stores aggregate totals, not per-package dimensions. For + // pallets we reconstruct the standard EUR pallet footprint (120×80 cm) and + // derive the height from the volume — so a default 0.96 CBM pallet comes back + // as 120×80×100. For loose parcels we fall back to a cube of equal volume. + let length: number; + let width: number; + let height: number; + if (isPalette) { + length = 120; + width = 80; + const baseM2 = (length / 100) * (width / 100); // 0.96 m² + height = perVolM3 > 0 ? Math.round((perVolM3 / baseM2) * 100 * 100) / 100 : 100; + } else { + const sideCm = perVolM3 > 0 ? Math.round(Math.cbrt(perVolM3) * 100 * 100) / 100 : 0; + length = sideCm; + width = sideCm; + height = sideCm; + } const pkg = { - type: (pallets > 0 ? 'palette' : 'colis') as Package['type'], + type: (isPalette ? 'palette' : 'colis') as Package['type'], quantity: q, - length: sideCm, - width: sideCm, - height: sideCm, - weight: wgt > 0 ? wgt / q : 0, + length, + width, + height, + weight: wgt > 0 ? Math.round((wgt / q) * 100) / 100 : 0, stackable: true, };