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) skipping existing start times (onConflictDoNothing), returns {created,skipped,slots}, 400 interval_too_short; matchesActiveSlot and public availability now filter by Riyadh weekday.
- UI (protocol.tsx): interval-generation form (from/to/duration + day toggle pills + workdays/all-days presets), 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, duplicate skipping, validation, weekday filtering in availability + booking rejection, viewer 403 on generate.
- Architect review: Pass; added the suggested authz test.
This commit is contained in:
@@ -361,6 +361,13 @@ export const protocolBookingSlotsTable = pgTable(
|
||||
// padded). Uniqueness is enforced so two slots can't start together.
|
||||
startTime: varchar("start_time", { length: 5 }).notNull(),
|
||||
durationMinutes: integer("duration_minutes").notNull().default(30),
|
||||
// Days of week (0=Sunday .. 6=Saturday, Riyadh calendar) on which this
|
||||
// slot is offered. Defaults to every day so pre-existing rows keep their
|
||||
// old behaviour.
|
||||
daysOfWeek: integer("days_of_week")
|
||||
.array()
|
||||
.notNull()
|
||||
.default([0, 1, 2, 3, 4, 5, 6]),
|
||||
isActive: boolean("is_active").notNull().default(true),
|
||||
sortOrder: integer("sort_order").notNull().default(0),
|
||||
createdBy: integer("created_by").references(() => usersTable.id, {
|
||||
|
||||
Reference in New Issue
Block a user