refactor(it-hilfe): stop auto-transitioning OPEN → IN_DISCUSSION on first offer

The IN_DISCUSSION request status was a dead state — auto-set when the
first offer arrived but never user-facing in any UI surface (no badge,
no filter tab, no transition button). It only added a fourth status to
reason about and bifurcated every "is this request still accepting
offers?" check across the codebase.

After this commit, the state machine going forward is:
  OPEN → MATCHED → COMPLETED   (or → CANCELLED at any point)

Backward-compat: the filter at offers/route.ts:158 still allows offers
on legacy IN_DISCUSSION rows, so existing data remains functional until
a follow-up session ships the DB migration to normalise rows + remove
the status from REQUEST_STATUS / VALID_REQUEST_TRANSITIONS / config
labels / admin stats / UI references.

First in a planned sequence to kill IN_DISCUSSION end-to-end per the
IT-Hilfe simplification roadmap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
g-butandClaude Opus 4.7 committed 2026-05-25 01:27:04 +02:00
1 parent 3745e4315f
commit e5a92e9403
1 file changed
+5 -9
@@ -212,20 +212,16 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
})
.returning({ id: itHilfeOffers.id })
// Increment offer count
// Increment offer count. Request status stays OPEN until an offer is
// accepted (→ MATCHED). The legacy `IN_DISCUSSION` auto-transition was
// removed — it was a dead state never surfaced in UI. Legacy rows with
// status='in_discussion' remain accepted by the filter at line 158
// until a follow-up DB migration normalises them to 'open'.
await db
.update(itHilfeRequests)
.set({ offerCount: sql`${itHilfeRequests.offerCount} + 1` })
.where(eq(itHilfeRequests.id, id))
// Update request status to in_discussion if it was open
if (requestData.status === REQUEST_STATUS.OPEN) {
await db
.update(itHilfeRequests)
.set({ status: REQUEST_STATUS.IN_DISCUSSION })
.where(eq(itHilfeRequests.id, id))
}
logger.info('Created IT-Hilfe offer', {
offerId: newOffer.id,
requestId: id,