Give Announcements date fields a timezone picker defaulting to the center's timezone

Aperta
#1,298 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
50/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, typescript
Ambito
backend, database

Direzione di ricerca

Start with src/collections/Announcements/index.ts and src/fields/startAndEndDateField/components/InitialTimezoneSetter.tsx, then review the dependency branch for the existing center timezone picker and setter behavior. Generate types, create the migration, and update the announcements seed; verify the additive migration with pnpm migrate:check and run the listed checks. Done means all acceptance criteria pass, including tests for the announcement field paths; wait for #1295 to merge before rebasing onto main.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement ready-for-agent

Follow-up to #1295 — Hardcode each center's timezone and default new event dates to it. Split out so the schema change ships on its own.

Problem

Announcements' startDate, endDate, and publishedAt are day-and-time fields with no timezone picker. The admin picker silently uses the editor's browser zone, so an editor in Mountain time who sets "show from 6:00 AM" for a Pacific center gets 6am Mountain, which is 5am for the center's readers. These fields drive visibility windows, so the mistake is user-facing.

Events and Courses already have the picker. #1295 makes it default to the center's timezone from AVALANCHE_CENTERS and flags when the chosen zone differs from the browser's. Announcements should get the same.

What to build

  • Add timezone: { supportedTimezones: TIMEZONE_OPTIONS } to the three Announcements date fields (src/collections/Announcements/index.ts).
  • Generalize the tenant-default setter in src/fields/startAndEndDateField/components/InitialTimezoneSetter.tsx so it takes its field paths as props instead of being hardwired to the event fields, and mount it on Announcements with startDate_tz driving endDate_tz and publishedAt_tz. Events must keep behaving exactly as they do now.
  • pnpm generate:types, then pnpm payload migrate:create add_announcement_timezones. Expect six additive ADD COLUMN ... text statements: three on announcements, three on _announcements_v because the collection has drafts. Run pnpm migrate:check.
  • Update the announcements seed to set the _tz fields and confirm pnpm seed completes.

Why no data migration

The stored value is already a UTC instant and _tz is only a display label. Existing rows keep a null _tz, getActiveAnnouncements and isExpired keep comparing instants unchanged, and the setter fills the center zone the next time someone opens the doc. A backfill of each tenant's zone is optional.

Dependencies

Branch from busbyk/plan-771-afp-drift-warnings until #1295 merges, then rebase and open against main. The center timezone constant, the America/Phoenix picker option, and the setter all live there.

Acceptance criteria

  • Announcements show a timezone picker on all three date fields, defaulting to the selected center's zone
  • The browser-mismatch note from #1295 appears on Announcements when the zones differ
  • Events and Courses behave exactly as before
  • Migration is additive only and pnpm migrate:check is clean
  • Tests cover the generalized setter with the announcement field paths
  • pnpm tsc, pnpm lint, pnpm test, pnpm fallow:audit, pnpm drift:check pass

Related

  • #1295 — Hardcode each center's timezone and default new event dates to it
  • #771 — Explicit timezones
  • #1292 — Announcements pins every /[center] route to a 60-second ISR window, so revalidate = 3600 has never taken effect. Different problem, same fields: that issue is about when the site notices a startDate or endDate boundary passing; this one is about the boundary being the instant the editor meant. If #1292 lands a scheduler that fires at those boundaries, this issue is what makes the boundary correct.
  • ADR 020 (docs/decisions/020-center-timezone-is-a-hardcoded-fact.md on the #1295 branch) for why the default comes from a hardcoded constant
Lingua principale
TypeScript
Stelle
6
Fork
2
Merge medio
1g 11h
PR unite (30g)
35

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NWACus/web

Tutte le issue di NWACus/web

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.