Feature/82 make coach selection mandatory for private lessons#96
Feature/82 make coach selection mandatory for private lessons#96maxiDeee wants to merge 2 commits into
Conversation
RenaudBernier
left a comment
There was a problem hiding this comment.
The error message just shows on first try to create service. It should show on every unsuccessful try.
Screen.Recording.2026-06-06.at.3.50.25.PM.mov
|
Fixed bug for error message only showing up once, updated screenshot. |
RenaudBernier
left a comment
There was a problem hiding this comment.
Looks good, works great!
martin0024
left a comment
There was a problem hiding this comment.
looks good, please run pnpm db:push before merging
|
you forgot to mention #82 |
|
To run pnpm to update the database, the CHECK constraint will fail to create if any existing private_lessons row has coach_id IS NULL(explained in Notes part of pr). Should I go ahead and delete these rows? |
you have two choices, either you backfill or you delete: option 1 backfill: UPDATE services
SET coach_id = '1a64052a-0612-4910-aa7d-5415b55d2973'
WHERE type = 'private_lessons' AND coach_id IS NULL;or option 2 DELETE FROM services
WHERE type = 'private_lessons' AND coach_id IS NULL;up to you, you can also accept what |
Closes #82
Overview
Private lessons could be created without a coach (the form validated
coach_idbut never saved it, and the column was nullable). This makes a coach mandatory for private lessons end to end, lets admins reassign the coach when editing, and prevents deleting a coach who is still assigned to a private lesson.coach_idFKset null→restrict, plus a partial CHECK (type <> 'private_lessons' OR coach_id IS NOT NULL) so private lessons require a coach while programs stay coachless.createServicenow persistscoachId;updateServicesupports reassignment while keeping the coach required. The dialog submits the coach via a hidden input (a Radix Select withnamesilently falls back to its first option) and pre-selects the current coach when editing.deleteUserAdminaction blocks deleting a coach assigned to a private lesson; surfaced in the Users tab via a delete button, confirm dialog, and error toast.updateServicerecreated the Stripe price on every edit, which archives the product's default price (rejected by Stripe). It now swaps the price only when the amount changes.Testing
pnpm testpasses 18/18 (11 new) covering the create, update, and delete actions;pnpm lintandtsc --noEmitare clean.Screenshots / Screencasts
Creating a private lesson without a coach is rejected:

Deleting a user assigned as coach to a private lesson is blocked:

Checklist
Notes
The schema change isn't applied to the DB yet — run
pnpm db:push. The CHECK constraint will fail to create if any existingprivate_lessonsrow hascoach_id IS NULL, so backfill those rows with a coach (or soft-delete them) first.Out of scope follow-up: editing a service's price still hits the Stripe "default price cannot be archived" error on a genuine price change; only the unchanged-price path is fixed here.