fix(applications): allow re-applying after withdrawing - #503
Merged
ralyodio merged 1 commit intoJul 21, 2026
Merged
Conversation
A withdrawn application still matched the 'already applied' check, so the applicant could never re-apply to the gig. Because there is no active application, the poster also cannot accept one, which blocks the applicant from ever creating an invoice for completed work. Re-scope the duplicate check to non-withdrawn applications, and reuse the existing row (reset to 'pending') when resubmitting, since the UNIQUE(gig_id, applicant_id) constraint forbids a second row. Adds a regression test covering resubmission after withdrawal and confirming an active application still blocks re-applying.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A withdrawn application still matched the "already applied" duplicate check in
POST /api/applications, so an applicant who withdrew could never re-apply to that gig (You have already applied to this gig). With no active application, the poster has nothing to accept, soPOST /api/gigs/{id}/invoicestays permanently gated onApplication must be accepted before creating an invoice. Net effect: completed, merged work can never be invoiced once an application has been withdrawn.Hit in practice on a live gig where a withdrawn application dead-ended both re-apply and invoicing.
Fix
statustopendingwith the new cover letter / rate / etc.) instead of inserting. TheUNIQUE(gig_id, applicant_id)constraint forbids a second row, so an insert would fail; an in-place update is correct.Tests
Added
src/app/api/applications/route.test.ts:statusreset topending. Fails before this change (400), passes after.pending) application continues to block re-applying (400).Full suite green locally:
vitest run-> 189 files / 1714 tests passed;tsc --noEmitclean; eslint clean on changed files.