diff --git a/frontend/src/components/OrdersPanel.vue b/frontend/src/components/OrdersPanel.vue index e42404dd..1eba51cd 100644 --- a/frontend/src/components/OrdersPanel.vue +++ b/frontend/src/components/OrdersPanel.vue @@ -159,6 +159,14 @@ const normalizeAmount = (value) => { return Math.max(0, Number(parsed.toFixed(2))); }; +const sortHistoryNewestFirst = (entries = []) => { + return [...entries].sort((a, b) => { + const aTime = new Date(a?.changedAt || a?.updatedAt || a?.createdAt || 0).getTime(); + const bTime = new Date(b?.changedAt || b?.updatedAt || b?.createdAt || 0).getTime(); + return bTime - aTime; + }); +}; + export default { name: 'OrdersPanel', props: { @@ -257,6 +265,7 @@ export default { cost: normalizeAmount(order.cost), paidAmount: normalizeAmount(order.paidAmount), openAmount: normalizeAmount(order.openAmount), + historyEntries: sortHistoryNewestFirst(order.historyEntries || []), draftItem: order.item || '', draftStatus: order.status || 'requested', draftCost: String(normalizeAmount(order.cost)),