Skip to content

Commit b5b4423

Browse files
0xdevcollinsclaude
andcommitted
fix(bounty): derive shortlist selection from live application list
Declining a checked application unmounted its checkbox but left its id in the checked set, so the sticky-bar count stayed inflated and Approve shortlist submitted a DECLINED application. Filter the selection against the current SUBMITTED rows so the count and the payload only ever include actionable applications. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent dced3cf commit b5b4423

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

components/organization/bounties/manage/BountyApplicationsPanel.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ export default function BountyApplicationsPanel({
104104
a.applicationStatus === 'SUBMITTED';
105105
const busy = select.isPending || shortlist.isPending || decline.isPending;
106106

107+
// `checked` can hold ids that have since left SUBMITTED (e.g. a checked
108+
// application was declined, unmounting its checkbox), so derive the
109+
// effective selection from the live list: the sticky-bar count and the
110+
// shortlist payload must never include a non-actionable application.
111+
const selectedIds = [...checked].filter(id =>
112+
applications.some(a => a.id === id && actionable(a))
113+
);
114+
107115
const toggleCheck = (id: string) =>
108116
setChecked(prev => {
109117
const next = new Set(prev);
@@ -122,7 +130,7 @@ export default function BountyApplicationsPanel({
122130
);
123131

124132
const onShortlist = () => {
125-
const applicationIds = [...checked];
133+
const applicationIds = selectedIds;
126134
if (
127135
overview.shortlistSize != null &&
128136
applicationIds.length > overview.shortlistSize
@@ -171,19 +179,19 @@ export default function BountyApplicationsPanel({
171179
{isCompetition && (
172180
<div className='sticky bottom-4 flex items-center justify-between gap-3 rounded-2xl border border-zinc-800 bg-zinc-950/90 p-4 backdrop-blur'>
173181
<span className='text-sm text-zinc-400'>
174-
{checked.size} selected
182+
{selectedIds.length} selected
175183
{overview.shortlistSize != null
176184
? ` (max ${overview.shortlistSize})`
177185
: ''}
178186
</span>
179187
<BoundlessButton
180-
disabled={checked.size === 0 || busy}
188+
disabled={selectedIds.length === 0 || busy}
181189
onClick={onShortlist}
182190
>
183191
{shortlist.isPending ? (
184192
<Loader2 className='h-4 w-4 animate-spin' />
185193
) : (
186-
`Approve shortlist (${checked.size})`
194+
`Approve shortlist (${selectedIds.length})`
187195
)}
188196
</BoundlessButton>
189197
</div>

0 commit comments

Comments
 (0)