Task #710: Weekly availability intervals (Calendly-style) for protocol booking slots
- DB: protocol_booking_slots.days_of_week integer[] NOT NULL default {0..6} (0=Sun..6=Sat, Riyadh); pushed via drizzle-kit, legacy rows keep all-days behaviour.
- API (routes/protocol.ts): slot create/patch accept daysOfWeek (validated, deduped, sorted); new POST /protocol/booking-slots/generate (requireManageRooms) generates stepped slots in [from,to); duplicate rule is day-scoped: same start time on a different day merges the days into the existing slot (existing duration kept), fully covered times skipped; returns {created,merged,skipped,slots}; manual POST create also merges disjoint days instead of 409; matchesActiveSlot and public availability filter by Riyadh weekday.
- UI (protocol.tsx): interval-generation form (from/to/duration + day toggle pills + workdays/all-days presets), toast shows created/merged/skipped, slot list shows day names, booking dialog filters slots by chosen date weekday with stale-selection reset and empty-day hint. i18n keys added (ar/en).
- Tests: 13/13 pass incl. generation, day-scoped merge (same time different day is NOT a duplicate), duplicate skipping, validation, weekday filtering in availability + booking rejection, viewer 403 on generate.
This commit is contained in:
@@ -2488,7 +2488,7 @@ function SlotsAdminSection({
|
||||
});
|
||||
const generateMut = useMutation({
|
||||
mutationFn: () =>
|
||||
apiJson<{ created: number; skipped: number }>(
|
||||
apiJson<{ created: number; merged: number; skipped: number }>(
|
||||
`${API}/protocol/booking-slots/generate`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -2503,10 +2503,11 @@ function SlotsAdminSection({
|
||||
onSuccess: (r) => {
|
||||
toast({
|
||||
title:
|
||||
r.created === 0
|
||||
r.created === 0 && r.merged === 0
|
||||
? t("protocol.slots.generatedNone")
|
||||
: t("protocol.slots.generated", {
|
||||
created: r.created,
|
||||
merged: r.merged,
|
||||
skipped: r.skipped,
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user