Skip to content

Commit

Permalink
fix adding names and sorted options
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon committed Apr 25, 2024
1 parent acc5441 commit 0911673
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/keystone/admin/components/Incentives/War.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export function War({ incentive, incentiveUpdate }: WarProps) {
-1,
);

const sortedOptions = [...incentiveRawData.options].sort((a, b) => b.total - a.total);

return (
<Stack gap="medium">
<FieldContainer>
Expand All @@ -142,7 +144,7 @@ export function War({ incentive, incentiveUpdate }: WarProps) {
<span></span>
<span>Total</span>
<span></span>
{incentiveRawData.options.map((item, i) => {
{sortedOptions.map((item, i) => {
return (
<>
<TextInput
Expand All @@ -151,7 +153,7 @@ export function War({ incentive, incentiveUpdate }: WarProps) {
handleNameChange(e.target.value, item.name);
}}
value={item.name}
key={`input-${item.name}`}
key={`input-${i}`}
/>
<TextInput
placeholder="Increment"
Expand All @@ -160,34 +162,34 @@ export function War({ incentive, incentiveUpdate }: WarProps) {
onChange={(e) => {
handleIncrementChange(e.target.valueAsNumber, i);
}}
key={`input-amount-${item.name}`}
key={`input-amount-${i}`}
/>
<Button
onClick={() => handleIncrement(i)}
isDisabled={increments[i] === 0}
tone="positive"
weight={increments[i] === 0 ? "light" : "bold"}
key={`add-${item.name}`}>
key={`add-${i}`}>
Add
</Button>
<span
style={{
fontWeight: highestNumber === item.total ? "bold" : "normal",
fontSize: "1.5rem",
}}
key={`total-${item.name}`}>
key={`total-${i}`}>
${item.total.toLocaleString()}
</span>
{item.name === "" ? (
<Button
onClick={() => handleRemove(i)}
tone="negative"
weight="light"
key={`remove-${item.name}`}>
key={`remove-${i}`}>
Remove
</Button>
) : (
<span key={`spacer-${item.name}`}></span>
<span key={`spacer-${i}`}></span>
)}
</>
);
Expand Down

0 comments on commit 0911673

Please sign in to comment.