diff --git a/resources/js/components/DigitalProgressBar.tsx b/resources/js/components/DigitalProgressBar.tsx index 04e44a1..d74df02 100644 --- a/resources/js/components/DigitalProgressBar.tsx +++ b/resources/js/components/DigitalProgressBar.tsx @@ -8,13 +8,13 @@ const BAR_COUNT = 20; function getGlow(index: number): string { if (index < 10) return '0 0 8px rgba(239, 68, 68, 0.6)'; - if (index < 18) return '0 0 8px rgba(249, 115, 22, 0.6)'; + if (index < BAR_COUNT - 1) return '0 0 8px rgba(249, 115, 22, 0.6)'; return '0 0 8px rgba(34, 197, 94, 0.6)'; } function getBarColor(index: number): string { if (index < 10) return 'bg-red-500'; - if (index < 18) return 'bg-orange-500'; + if (index < BAR_COUNT - 1) return 'bg-orange-500'; return 'bg-green-500'; } diff --git a/resources/js/pages/Scenarios/Show.tsx b/resources/js/pages/Scenarios/Show.tsx index c86b122..248f261 100644 --- a/resources/js/pages/Scenarios/Show.tsx +++ b/resources/js/pages/Scenarios/Show.tsx @@ -1,6 +1,6 @@ import { Head, router } from '@inertiajs/react'; import { Settings } from 'lucide-react'; -import { useRef, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import BucketCard from '@/components/BucketCard'; import DistributionLines from '@/components/DistributionLines'; import InlineEditInput from '@/components/InlineEditInput'; @@ -66,6 +66,20 @@ export default function Show({ scenario, buckets }: Props) { const [isDistributing, setIsDistributing] = useState(false); const [isSaving, setIsSaving] = useState(false); const [distributionError, setDistributionError] = useState(null); + // Sync editingBucket with refreshed props after inline edits. + // Only react to buckets changing, not editingBucket — reading .id is stable. + useEffect(() => { + if (editingBucket) { + const updated = buckets.data.find(b => b.id === editingBucket.id); + if (updated) { + setEditingBucket(updated); + } else { + setEditingBucket(null); + } + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [buckets]); + const containerRef = useRef(null); const incomeRef = useRef(null); const bucketRefs = useRef>(new Map());