feat(OrdersPanel): implement sorting for order history entries
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 42s
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:
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user