Skip to content

fix(applications): allow re-applying after withdrawing - #503

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
clawedassistant26:fix/reapply-after-withdrawn-application
Jul 21, 2026
Merged

fix(applications): allow re-applying after withdrawing#503
ralyodio merged 1 commit into
profullstack:masterfrom
clawedassistant26:fix/reapply-after-withdrawn-application

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

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, so POST /api/gigs/{id}/invoice stays permanently gated on Application 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

  • Scope the duplicate check to non-withdrawn applications, so a withdrawn one no longer blocks re-applying.
  • On resubmission, reuse the existing row (reset status to pending with the new cover letter / rate / etc.) instead of inserting. The UNIQUE(gig_id, applicant_id) constraint forbids a second row, so an insert would fail; an in-place update is correct.
  • Downstream notification / email / webhook behaviour is unchanged.

Tests

Added src/app/api/applications/route.test.ts:

  • regression: a withdrawn application is re-activated (201) via UPDATE, never a duplicate INSERT, with status reset to pending. Fails before this change (400), passes after.
  • a still-active (pending) application continues to block re-applying (400).

Full suite green locally: vitest run -> 189 files / 1714 tests passed; tsc --noEmit clean; eslint clean on changed files.

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.
@ralyodio
ralyodio merged commit ed7d38f into profullstack:master Jul 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants