feat: richer recurrence options + recurring template editing#45
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Description
Extends the recurring event system with richer schedule options and the ability to edit active templates.
Schema additions (recurring_events table — migration 0031):
days_of_week (integer[]) — selected days for weekly/biweekly patterns
weekdays_only (boolean) — daily events skip weekends when true
monthly_type (varchar) — "day-of-month" or "nth-weekday"
monthly_nth (integer) — which occurrence (1–4, -1 = Last)
monthly_weekday (integer) — weekday for nth-weekday monthly patterns
Cron logic (/api/cron/recurring-events): rewrote occursOnDate() to handle all four frequency types with the new fields. Legacy records with null daysOfWeek fall back to the template's start date day-of-week.
Creation form (RecurringEventCreationForm): UI for all new schedule options — multi-day toggle group for weekly, biweekly single-day select, monthly radio (day-of-month vs. nth-weekday) with corresponding dropdowns. Form now also supports edit mode via an initialValues prop, with immutable fields (frequency, schedule, location, times) shown disabled.
API (/api/recurring-events): added PUT handler for editing title, description, capacity, and end date. Validation added for new fields in POST.
Templates list (RecurringEventsClient): replaced flat frequency labels with a human-readable formatRecurrence() summary (e.g. "Weekly on Mo, We, Fr", "Monthly — 2nd Tuesday"). Edit button (navigates to edit page) and Stop button are both hidden for stopped templates.
Edit page (/dashboard/recurring-event/[id]/edit): full-page edit form mirroring the events library edit pattern. Stopped templates redirect away server-side.
Relevant Issues
N/A
How to Test
Run pnpm drizzle-kit generate then pnpm drizzle-kit migrate to apply migration 0031.
Create recurring events with each frequency type and verify the correct schedule description appears in the templates table.
Click the edit icon on an active template — verify immutable fields (frequency, times, location) are disabled and only title/description/capacity/end date save.
Stop a template — verify both the edit and stop buttons disappear and the edit URL redirects back to /dashboard/recurring-event.
POST to /api/cron/recurring-events with a valid x-api-key header and confirm only templates matching today's date pattern generate events.
Miscellaneous Notes
The Netlify cron (schedule: "0 0 * * *") fires at midnight UTC (≈ 8 PM EDT), creating that UTC calendar day's events ~14 hours before the day begins locally. Idempotency check prevents duplicates if the endpoint is called multiple times.
Legacy weekly/biweekly templates with null daysOfWeek continue to work via startDate day-of-week fallback — no backfill needed.
There is a stale .bak file (RecurringEventsClient.tsx.bak) in the recurring-event directory that should be deleted before merging.