Skip to content

fix(group-wizard): use MP-TZ for Start_Date default#17

Merged
chriskehayias merged 3 commits into
mainfrom
fix/group-wizard-start-date-mp-tz
May 21, 2026
Merged

fix(group-wizard): use MP-TZ for Start_Date default#17
chriskehayias merged 3 commits into
mainfrom
fix/group-wizard-start-date-mp-tz

Conversation

@chriskehayias
Copy link
Copy Markdown
Contributor

Summary

The group wizard's Start_Date default was computed at module load via new Date().toISOString().split('T')[0] — today in UTC. For an MP domain east of UTC late at night, or west of UTC any evening past the MP-TZ rollover, the form pre-populated with tomorrow's MP-TZ date. This closes the one remaining MP-bound anti-pattern site that PR #15 left behind.

  • New buildGroupWizardDefaults(mpTimezone) factory formats today via Intl.DateTimeFormat({ timeZone }) in the MP domain's IANA zone.
  • page.tsx now awaits getMpTimezone() and threads it to <GroupWizard> (Recipe C from the playbook).
  • helper.ts JSDoc and docs/README.md updated so the Contact_Date: new Date().toISOString() example no longer steers contributors back into the anti-pattern.

Commits in this PR

Three commits — only the last is part of this fix:

  1. a22f550 — adds the date/time handling playbook (.claude/playbooks/port-mp-datetime-handling.md) that drove the work.
  2. 018aabd — unrelated setup wizard polish, already on local main and bundled to ship together.
  3. ca059b4 — the actual Start_Date fix.

Test plan

  • npm run test:run — full suite 667/667 pass (+3 new factory tests).
  • npm run lint — clean.
  • npx tsc --noEmit — only pre-existing errors in unrelated test files (helper.test.ts, provider.test.ts, logger.test.ts, word-document.test.ts); none touched here.
  • Service + schema tests pass under TZ=UTC and TZ=America/Los_Angeles (52/52 each).
  • Grep confirms no remaining MP-bound T00:00:00Z / .toISOString() / new Date(...).get*() sites in src/.

🤖 Generated with Claude Code

chriskehayias and others added 3 commits May 21, 2026 07:18
- setup.ts step 9: default the storedprocs prompt to true (was false); drop
  "(optional)" from step name; print a one-line context message explaining
  what the reference is used for (Claude Code stored-proc suggestions)
- README.md: wizard description now says "Generate the stored procedure
  reference (powers Claude Code suggestions)" instead of "Optionally
  generate..."; rename manual setup section to "Regenerate Ministry Platform
  Types" and note that models ship pre-generated so a fresh clone can build
  immediately — regeneration is for picking up your own MP instance's custom
  schema; mention the storedprocs script alongside

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The wizard's Start_Date default was built at module load with
`new Date().toISOString().split('T')[0]`, which returns today in
the browser's UTC offset. For an MP domain east of UTC late at
night (or west of UTC at any evening hour past the MP-TZ rollover),
the form pre-populated with tomorrow's MP-TZ date.

- schema.ts: clear `GROUP_WIZARD_DEFAULTS.Start_Date` and add a
  `buildGroupWizardDefaults(mpTimezone)` factory that formats today
  via `Intl.DateTimeFormat({ timeZone })`.
- index.ts: re-export the factory.
- page.tsx: await `getMpTimezone()` and pass to <GroupWizard>.
- group-wizard.tsx: accept `mpTimezone` prop, call the factory for
  `defaultValues` and `handleCreateAnother` reset.
- schema.test.ts: cross-zone correctness check (UTC vs +14 zone).
- group-wizard.test.tsx: supply `mpTimezone` to 10 render sites.
- helper.ts JSDoc + docs/README.md: replace
  `Contact_Date: new Date().toISOString()` example with
  `await tz.toMpSqlDatetime(new Date())` so future contributors
  don't copy the anti-pattern.

Tests: +3 new factory tests, full suite 667/667 passes under
TZ=UTC and TZ=America/Los_Angeles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chriskehayias chriskehayias merged commit facacd0 into main May 21, 2026
1 check passed
@chriskehayias chriskehayias deleted the fix/group-wizard-start-date-mp-tz branch May 21, 2026 11:46
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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