From 1f477a4458971bc16bd1ab7c138899a07b569510 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 22 Apr 2026 09:47:52 +0200 Subject: [PATCH] feat(OrdersPanel): implement sorting for order history entries - Added a new function to sort order history entries in descending order based on their timestamps. - Integrated the sorting function into the OrdersPanel component to enhance the display of order history. --- frontend/src/components/OrdersPanel.vue | 9 +++++++++ 1 file changed, 9 insertions(+) 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)),