feat(OrdersPanel): implement sorting for order history entries
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 42s

- 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.
This commit is contained in:
Torsten Schulz (local)
2026-04-22 09:47:52 +02:00
parent 1d67b68b44
commit 1f477a4458

View File

@@ -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)),