Feature/82 make coach selection mandatory for private lessons#96
Open
maxiDeee wants to merge 2 commits into
Open
Feature/82 make coach selection mandatory for private lessons#96maxiDeee wants to merge 2 commits into
maxiDeee wants to merge 2 commits into
Conversation
RenaudBernier
requested changes
Jun 6, 2026
Member
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
Author
|
Fixed bug for error message only showing up once, updated screenshot. |
RenaudBernier
approved these changes
Jun 7, 2026
Member
RenaudBernier
left a comment
There was a problem hiding this comment.
Looks good, works great!
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.
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.