Skip to content

Warn before approving a request that double-books the teacher - #50

Merged
yt314 merged 1 commit into
mainfrom
warn-before-double-booking
Sep 19, 2026
Merged

yt314 merged 1 commit into
mainfrom
warn-before-double-booking

Conversation

@yt314

@yt314 yt314 commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

The app already warns about double-booking — but only where the teacher types a time herself. preSaveWarning runs when she creates a lesson and when she edits its time. It does not run when she approves a request.

Those are exactly the two places where the time was chosen by someone else, so they are where she is least likely to have checked her own calendar first.

Reproduced against the running app

A parent requested a lesson for נועה ברגר at 16/09 17:00 — an hour when יעל כהן already had a scheduled lesson.

DIALOG: פרטי שיעור  תלמיד: נועה ברגר  מועד: 16/09/2026 17:00 – 18:00  סטטוס: ממתין לאישור  דחה  אשר
ANY DOUBLE-BOOKING WARNING? NO
AFTER APPROVE: הבקשה אושרה

And in the database:

 FullName  |       StartTime        |        EndTime         |  Status
-----------+------------------------+------------------------+-----------
 יעל כהן   | 2026-09-16 14:00:00+00 | 2026-09-16 15:00:00+00 | Scheduled
 נועה ברגר | 2026-09-16 14:00:00+00 | 2026-09-16 15:00:00+00 | Scheduled

Two students, one hour, no warning anywhere. The same held for a parent's proposed new time on an existing lesson.

The fix

Both approval paths now use the warning that already existed, in two layers:

In the dialog, so she can decline instead of approving:

DIALOG: … סטטוס: ממתין לאישור  כבר קיים שיעור עם יעל כהן בשעה 17:00–18:00.  דחה  אשר
DIALOG WARNS ABOUT THE CLASH? yes

On approve, so it cannot be skimmed past:

PROMPT: שים לב  כבר קיים שיעור עם יעל כהן בשעה 17:00–18:00. לאשר בכל זאת?  ביטול  אשר בכל זאת
STILL PENDING AFTER CANCEL? yes

Same for a proposed new time:

DIALOG: בקשת שינוי מועד  תלמיד: יעל כהן  הורה מבקש: דוד כהן
        מועד נוכחי: 16/09/2026 17:00 – 18:00  מועד מוצע: 17/09/2026 18:00 – 19:00
        כבר קיים שיעור עם נועה ברגר בשעה 18:00–19:00.
CONFIRM ASKED? yes

And a free slot produces neither — no false positives:

מועד מוצע: 18/09/2026 08:00 – 09:00
RESCHEDULE DIALOG WARNS? NO
CONFIRM ASKED? NO

The conflict lookup runs against the full lesson list (lessons() is loaded unfiltered), so a proposed date outside the month on screen is still checked.

Deliberately not covered: recurring series

saveRecurringLesson has no conflict check either, and I left it that way. Its occurrences are generated on the server by LessonSeriesGenerator, which skips Jewish holidays and rolls forward on a horizon — so a client-side check would either miss occurrences or warn about ones that will never be created. A warning that silently checks only the first week is worse than none, because "no warning" would read as "the whole series is clear". That check belongs next to the generator, as a separate change.

Testing

  • npx ng build — clean.
  • npx vitest run — 30 passing.
  • Every transcript above is from the running app, before and after.

Demo data restored and verified: 12 / 12 / 15 lessons per student, 4 teachers, 0 overlapping scheduled lessons, 0 change requests. The lesson the test moved was put back to 2026-09-16 14:00:00+00.

The double-booking check existed only where the teacher types a time
herself. Approving a lesson request or a proposed new time went straight
through — and those are exactly the two places where the time was chosen by
someone else, so she is least likely to have looked at her own calendar
first.

Reproduced against the running app: a parent requested a lesson at an hour
another student already had. The dialog said only "סטטוס: ממתין לאישור",
approving it said only "הבקשה אושרה", and the database then held two
Scheduled lessons for the same hour.

Both approval paths now use the warning that already existed, in two layers:
the clash is named in the dialog, so she can decline instead of approving,
and approving anyway asks first. A free slot produces neither.

Not covered, deliberately: creating a recurring series. Its occurrences are
generated on the server, which skips Jewish holidays, so a client-side check
would either miss occurrences or invent ones. That check belongs next to the
generator.
@vercel

vercel Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
talmidon Ready Ready Preview Sep 18, 2026 10:53am UTC

@yt314
yt314 merged commit f14a581 into main Sep 19, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Preview — c732e0bf Deployed Sep 18, 2026 by vercel[bot]
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.

1 participant