Skip to content

feat: add settings, profile, and sms consent backend services#107

Merged
kevinrutledge merged 5 commits intodevelopfrom
feat/settings-profile-backend
Apr 5, 2026
Merged

feat: add settings, profile, and sms consent backend services#107
kevinrutledge merged 5 commits intodevelopfrom
feat/settings-profile-backend

Conversation

@kevinrutledge
Copy link
Copy Markdown
Collaborator

Developer

Kevin Rutledge

What changed?

Added backend services, server actions, and Zod schemas for the Profile and Settings pages.

  1. Profile service (src/services/profile.ts) - getMemberProfile() fetches member data via getMemberById(), splits ownername into firstName/lastName, and returns a typed profile shape with role. Name splitting handled by a new splitName() utility in src/utils/name.ts.

  2. SMS consent service (src/services/sms-consent.ts) - three functions for the Settings page SMS consent card: getMemberSmsConsent() returns the active consent record, hasActiveConsent() does a boolean check, and revokeSmsConsent() sets revokedAt on all active consent records for a member.

  3. User preference service (src/services/user-preference.ts) - getUserPreferences() returns the member's global notification defaults (notifyEmailDefault, notifySmsDefault) or falls back to defaults if no row exists. updateUserPreferences() upserts the row.

  4. Zod schemas (src/schema/settings.ts) - UpdatePreferencesSchema requires at least one preference field (same refine pattern as UpdateNotificationSchema in schema/contact-group.ts). RevokeSmsConsentSchema validates method and optional message.

  5. Server actions - fetchProfile(), fetchSmsConsent(), revokeSmsConsentAction(), fetchUserPreferences(), updateUserPreferencesAction(). All call verifySession() first and return ActionResult following existing patterns.

How to test

  1. Run npx prisma generate - client generates without errors
  2. Run npm run build - succeeds
  3. Run npm run lint - no errors

Checklist

@kevinrutledge kevinrutledge self-assigned this Apr 5, 2026
@kevinrutledge kevinrutledge merged commit 5dc3937 into develop Apr 5, 2026
2 checks passed
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