Skip to content

Commit 0ffc6b2

Browse files
samejrclaude
andcommitted
Reset PurchaseSchedulesModal bundle state on each open
Previously the bundle stepper only re-synced when extraSchedules/stepSize props changed. Opening the modal, typing a value, cancelling, and reopening left the stale draft visible — confusing because the new total on the summary no longer matched the user's intent. The existing `lastSubmission as any` cast matches the codebase's established pattern (8 other sites) — left as-is rather than diverging. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3ee7c88 commit 0ffc6b2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

apps/webapp/app/components/schedules/PurchaseSchedulesModal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,18 @@ export function PurchaseSchedulesModal({
6565

6666
const stepSize = schedulePricing.stepSize;
6767
const [bundles, setBundles] = useState(Math.round(extraSchedules / stepSize));
68-
useEffect(() => {
69-
setBundles(Math.round(extraSchedules / stepSize));
70-
}, [extraSchedules, stepSize]);
7168
const amountValue = bundles * stepSize;
7269
const isLoading = fetcher.state !== "idle";
7370

7471
const [open, setOpen] = useState(false);
72+
// Reset the bundle stepper to the user's current extra-schedules count on
73+
// each open. Earlier this only re-synced when `extraSchedules`/`stepSize`
74+
// props changed, so if the user opened the modal, typed a value, cancelled,
75+
// and reopened without purchasing, the stale draft persisted.
76+
useEffect(() => {
77+
if (open) setBundles(Math.round(extraSchedules / stepSize));
78+
}, [open, extraSchedules, stepSize]);
79+
7580
useEffect(() => {
7681
const data = fetcher.data;
7782
if (

0 commit comments

Comments
 (0)