From aca9644c5b8f2ae5ce03a66db04faccf492b2720 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sun, 22 Mar 2026 02:05:43 +0100 Subject: [PATCH] 18 - Add inline editing for name, allocation type, and allocation value --- resources/js/pages/Scenarios/Show.tsx | 41 +++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/resources/js/pages/Scenarios/Show.tsx b/resources/js/pages/Scenarios/Show.tsx index fb21400..9109e79 100644 --- a/resources/js/pages/Scenarios/Show.tsx +++ b/resources/js/pages/Scenarios/Show.tsx @@ -71,6 +71,11 @@ const bucketTypeOptions = [ { value: 'want', label: 'Want' }, ]; +const allocationTypeOptions = [ + { value: 'fixed_limit', label: 'Fixed Limit' }, + { value: 'percentage', label: 'Percentage' }, +]; + /** Convert cents to dollars for display */ const centsToDollars = (cents: number): number => cents / 100; @@ -269,7 +274,11 @@ export default function Show({ scenario, buckets, streams = { data: [] }, stream

- {bucket.name} + patchBucket(bucket.id, { name: val })} + />

Priority {bucket.priority} •{' '} @@ -280,7 +289,14 @@ export default function Show({ scenario, buckets, streams = { data: [] }, stream displayLabel={bucket.type_label} disabled={bucket.type === 'overflow'} /> - {' '}• {bucket.allocation_type_label} + {' '}•{' '} + patchBucket(bucket.id, { allocation_type: val, allocation_value: null })} + displayLabel={bucket.allocation_type_label} + disabled={bucket.type === 'overflow'} + />

@@ -325,7 +341,26 @@ export default function Show({ scenario, buckets, streams = { data: [] }, stream
- Allocation: {formatAllocationValue(bucket)} + Allocation:{' '} + {bucket.allocation_type === 'fixed_limit' && bucket.allocation_value !== null ? ( + patchBucket(bucket.id, { allocation_value: dollarsToCents(val) })} + formatDisplay={(v) => `$${v.toFixed(2)}`} + min={0} + step="0.01" + /> + ) : bucket.allocation_type === 'percentage' && bucket.allocation_value !== null ? ( + patchBucket(bucket.id, { allocation_value: percentToBasisPoints(val) })} + formatDisplay={(v) => `${v.toFixed(2)}%`} + min={0} + step="0.01" + /> + ) : ( + formatAllocationValue(bucket) + )} {bucket.allocation_type === 'fixed_limit' && (