From 0911673cf31a7d8dad345f5cc3221f4e93f16ebb Mon Sep 17 00:00:00 2001 From: Ewan Lyon Date: Thu, 25 Apr 2024 23:18:56 +1000 Subject: [PATCH] fix adding names and sorted options --- .../keystone/admin/components/Incentives/War.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/keystone/admin/components/Incentives/War.tsx b/apps/keystone/admin/components/Incentives/War.tsx index a2bd13e..f62d597 100644 --- a/apps/keystone/admin/components/Incentives/War.tsx +++ b/apps/keystone/admin/components/Incentives/War.tsx @@ -116,6 +116,8 @@ export function War({ incentive, incentiveUpdate }: WarProps) { -1, ); + const sortedOptions = [...incentiveRawData.options].sort((a, b) => b.total - a.total); + return ( @@ -142,7 +144,7 @@ export function War({ incentive, incentiveUpdate }: WarProps) { Total - {incentiveRawData.options.map((item, i) => { + {sortedOptions.map((item, i) => { return ( <> { handleIncrementChange(e.target.valueAsNumber, i); }} - key={`input-amount-${item.name}`} + key={`input-amount-${i}`} /> + key={`total-${i}`}> ${item.total.toLocaleString()} {item.name === "" ? ( @@ -183,11 +185,11 @@ export function War({ incentive, incentiveUpdate }: WarProps) { onClick={() => handleRemove(i)} tone="negative" weight="light" - key={`remove-${item.name}`}> + key={`remove-${i}`}> Remove ) : ( - + )} );