Notification preferences (migration 048): - Per-member opt-out of muteable categories (bookings, classes, forms, admin alerts); billing is always-on. Opt-out model, default on. - Dispatcher reads prefs and marks muted outbox rows 'skipped' instead of sending; pure isMuted logic, fail-open on a prefs lookup error. - notification_preferences table (default-deny RLS); /me toggles and self-view via validated service-client actions. Alternate dues payment methods (migration 049): - Admin sets external pay-here URLs per platform (PayPal/Zeffy/Venmo) in /settings; members see active ones on /me and pay off-platform; the treasurer reconciles manually (platform pre-tagged). https-only. - dues_payment_methods table (SELECT space member, write admin/board). /me visual pass: - Restore the chip/preset profile editor (skills/interests/willing-to/ affiliations); promote ChipInput and presets to shared modules. - Gate the Stripe pay-dues button on whether the space has Stripe configured; show external links or a contact-admin note otherwise.
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { createClient } from '@/lib/supabase/server'
|
|
import SettingsClient from './settings-client'
|
|
import { StripeBillingPanel } from '@/components/settings/stripe-billing-panel'
|
|
import { DuesPaymentMethodsPanel } from '@/components/settings/dues-payment-methods-panel'
|
|
import { redirect } from 'next/navigation'
|
|
|
|
export default async function SettingsPage() {
|
|
const supabase = await createClient()
|
|
const { data: { user } } = await supabase.auth.getUser()
|
|
if (!user) redirect('/login')
|
|
|
|
const { data: member } = await supabase
|
|
.from('space_members').select('space_id, role').eq('user_id', user.id).in('status', ['current', 'unverified', 'late']).single()
|
|
|
|
if (!member) redirect('/login')
|
|
|
|
// Settings is admin-only. Gate on the server BEFORE fetching space config
|
|
// and integration state so non-admins never receive it. Board/treasurer
|
|
// use /customize for the things they can change.
|
|
const isAdmin = member.role === 'admin'
|
|
if (!isAdmin) redirect('/dashboard')
|
|
|
|
const { data: space } = await supabase
|
|
.from('spaces').select('*').eq('id', member.space_id).single()
|
|
|
|
const { data: integrations } = await supabase
|
|
.from('integrations').select('*').eq('space_id', member.space_id)
|
|
|
|
return (
|
|
<>
|
|
<SettingsClient
|
|
space={space}
|
|
isAdmin={isAdmin}
|
|
integrations={integrations ?? []}
|
|
currentRole={member.role}
|
|
/>
|
|
<StripeBillingPanel spaceId={member.space_id} />
|
|
<DuesPaymentMethodsPanel />
|
|
</>
|
|
)
|
|
}
|