feat: Customize hub + roles editor, terminal logo, invite links
IA refactor and the custom-roles editor pass 11 left as data-only. Customize hub: - New /customize (admin/board) with a left section rail: Roles, Membership tiers, Areas, Invite codes, Onboarding. - One focused module per panel under app/(app)/customize/panels/ plus a shared card and types file. The client shell is ~75 lines; each panel is self-contained (smart separation of concerns). - Settings slimmed to Space, Integrations, Webhooks. Removed the Roles/Tiers/Invites/Onboarding tabs and the Areas block from settings-client.tsx (~700 lines) and the matching fetches from settings/page.tsx. Dead props/state/types removed. - Sidebar: added a Customize NavLink (admin/board). Roles editor: - Rename/recolor the five built-in roles (upsertRoleLabel) and full CRUD on custom org roles. Adds the read path the audit flagged as missing: lib/role-labels.ts (getRoleLabelMap/roleDisplayName) is consumed in (app)/layout.tsx so the sidebar shows the renamed role. Logo: - Reverted the brand mark to the terminal >_ glyph (components/brand-mark.tsx) on the landing nav/footer, onboarding header, and favicon (public/logo.svg). Removed the dead local IcoTerminal. AtlasLogo stays only on the resources project page. Invite links: - InvitesPanel has Copy code and Copy link (/signup?invite=CODE). signup reads ?invite= on mount, prefills the code, preselects join. Deferred and tracked in HANDOFF: types/database.ts sync, renamed-role display on the members table, splitting the still-large settings-client.tsx, custom-role assignment UI. 266/266 tests pass. Production build clean; /customize, /onboarding, slimmed /settings all in the route table. No migration this pass.
This commit is contained in:
@@ -18,31 +18,6 @@ export default async function SettingsPage() {
|
||||
const { data: integrations } = await supabase
|
||||
.from('integrations').select('*').eq('space_id', member.space_id)
|
||||
|
||||
const { data: areas } = await supabase
|
||||
.from('space_areas')
|
||||
.select('id, code, name, icon, sort_order, is_archived')
|
||||
.eq('space_id', member.space_id)
|
||||
.order('sort_order', { ascending: true })
|
||||
.order('name', { ascending: true })
|
||||
|
||||
const { data: tiers } = await supabase
|
||||
.from('space_tiers')
|
||||
.select('id, slug, name, description, monthly_price_cents, billing_cadence, is_system, is_archived, sort_order')
|
||||
.eq('space_id', member.space_id)
|
||||
.order('sort_order', { ascending: true })
|
||||
|
||||
const { data: invites } = await supabase
|
||||
.from('space_invites')
|
||||
.select('id, code, label, expires_at, max_uses, uses_count, is_enabled, created_at')
|
||||
.eq('space_id', member.space_id)
|
||||
.order('created_at', { ascending: false })
|
||||
|
||||
const { data: onboardingSteps } = await supabase
|
||||
.from('space_onboarding_steps')
|
||||
.select('id, step_key, step_type, title, body, config, is_enabled, is_required, is_system, sort_order')
|
||||
.eq('space_id', member.space_id)
|
||||
.order('sort_order', { ascending: true })
|
||||
|
||||
const isAdmin = member?.role === 'admin'
|
||||
|
||||
return (
|
||||
@@ -51,47 +26,6 @@ export default async function SettingsPage() {
|
||||
isAdmin={isAdmin}
|
||||
integrations={integrations ?? []}
|
||||
currentRole={member.role}
|
||||
areas={(areas ?? []) as Array<{
|
||||
id: string
|
||||
code: string
|
||||
name: string
|
||||
icon: string | null
|
||||
sort_order: number
|
||||
is_archived: boolean
|
||||
}>}
|
||||
tiers={(tiers ?? []) as Array<{
|
||||
id: string
|
||||
slug: string
|
||||
name: string
|
||||
description: string | null
|
||||
monthly_price_cents: number
|
||||
billing_cadence: string
|
||||
is_system: boolean
|
||||
is_archived: boolean
|
||||
sort_order: number
|
||||
}>}
|
||||
invites={(invites ?? []) as Array<{
|
||||
id: string
|
||||
code: string
|
||||
label: string | null
|
||||
expires_at: string | null
|
||||
max_uses: number | null
|
||||
uses_count: number
|
||||
is_enabled: boolean
|
||||
created_at: string
|
||||
}>}
|
||||
onboardingSteps={(onboardingSteps ?? []) as Array<{
|
||||
id: string
|
||||
step_key: string
|
||||
step_type: 'welcome' | 'code_of_conduct' | 'profile' | 'payment' | 'content'
|
||||
title: string
|
||||
body: string | null
|
||||
config: Record<string, unknown>
|
||||
is_enabled: boolean
|
||||
is_required: boolean
|
||||
is_system: boolean
|
||||
sort_order: number
|
||||
}>}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,74 +6,21 @@ import { updateSpaceSettings, saveIntegration, disconnectIntegration, rotateWebh
|
||||
import { toast } from 'sonner'
|
||||
import { financialVisibilities, directoryVisibilities } from '@/lib/validations'
|
||||
|
||||
type Area = {
|
||||
id: string
|
||||
code: string
|
||||
name: string
|
||||
icon: string | null
|
||||
sort_order: number
|
||||
is_archived: boolean
|
||||
}
|
||||
import type { Tables } from '@/types/database'
|
||||
|
||||
type Space = Tables<'spaces'>
|
||||
type Integration = Tables<'integrations'>
|
||||
|
||||
// Roles, tiers, areas, invites, and onboarding moved to the dedicated
|
||||
// /customize hub. This page now owns space identity, visibility,
|
||||
// integrations, and webhooks only.
|
||||
interface Props {
|
||||
space: Space
|
||||
isAdmin: boolean
|
||||
integrations: Integration[]
|
||||
currentRole: string
|
||||
areas: Area[]
|
||||
tiers: Tier[]
|
||||
invites: Invite[]
|
||||
onboardingSteps: OnboardingStep[]
|
||||
}
|
||||
|
||||
export interface OnboardingStep {
|
||||
id: string
|
||||
step_key: string
|
||||
step_type: 'welcome' | 'code_of_conduct' | 'profile' | 'payment' | 'content'
|
||||
title: string
|
||||
body: string | null
|
||||
config: Record<string, unknown>
|
||||
is_enabled: boolean
|
||||
is_required: boolean
|
||||
is_system: boolean
|
||||
sort_order: number
|
||||
}
|
||||
|
||||
export interface Tier {
|
||||
id: string
|
||||
slug: string
|
||||
name: string
|
||||
description: string | null
|
||||
monthly_price_cents: number
|
||||
billing_cadence: string
|
||||
is_system: boolean
|
||||
is_archived: boolean
|
||||
sort_order: number
|
||||
}
|
||||
|
||||
export interface Invite {
|
||||
id: string
|
||||
code: string
|
||||
label: string | null
|
||||
expires_at: string | null
|
||||
max_uses: number | null
|
||||
uses_count: number
|
||||
is_enabled: boolean
|
||||
created_at: string
|
||||
}
|
||||
|
||||
const ROLES_INFO = [
|
||||
{ name: 'Admin', color: 'text-primary', description: 'Full access. Secrets, roles, integrations, all data.', permissions: ['ALL ACCESS'] },
|
||||
{ name: 'Board', color: 'text-primary', description: 'Members, payments, projects, board secrets.', permissions: ['MEMBERS', 'PAYMENTS', 'PROJECTS'] },
|
||||
{ name: 'Treasurer', color: 'text-primary', description: 'Payments, financial secrets, member payment status.', permissions: [] },
|
||||
{ name: 'Member', color: 'text-foreground', description: 'Tasks, chores, projects, public KB, comms.', permissions: [] },
|
||||
{ name: 'Associate', color: 'text-foreground', description: 'Read-only most areas. Can claim chores.', permissions: [] },
|
||||
]
|
||||
|
||||
const INTEGRATIONS_CONFIG = [
|
||||
{
|
||||
platform: 'paypal',
|
||||
@@ -138,17 +85,8 @@ const INTEGRATIONS_CONFIG = [
|
||||
},
|
||||
]
|
||||
|
||||
export default function SettingsClient({ space, isAdmin, integrations, currentRole, areas: initialAreas, tiers: initialTiers, invites: initialInvites, onboardingSteps: initialOnboarding }: Props) {
|
||||
const [activeTab, setActiveTab] = useState<'space' | 'roles' | 'tiers' | 'invites' | 'onboarding' | 'integrations' | 'webhooks'>('space')
|
||||
const [onboardingSteps, setOnboardingSteps] = useState<OnboardingStep[]>(initialOnboarding)
|
||||
const [areas, setAreas] = useState<Area[]>(initialAreas)
|
||||
const [tiers, setTiers] = useState<Tier[]>(initialTiers)
|
||||
const [invites, setInvites] = useState<Invite[]>(initialInvites)
|
||||
const [showNewTier, setShowNewTier] = useState(false)
|
||||
const [newTier, setNewTier] = useState({ slug: '', name: '', description: '', monthly_price_cents: 0, billing_cadence: 'monthly' as 'monthly' | 'quarterly' | 'annual' | 'one_time' | 'custom' })
|
||||
const [showNewInvite, setShowNewInvite] = useState(false)
|
||||
const [newInvite, setNewInvite] = useState({ code: '', label: '', expires_at: '', max_uses: '' })
|
||||
const [newArea, setNewArea] = useState({ code: '', name: '' })
|
||||
export default function SettingsClient({ space, isAdmin, integrations, currentRole }: Props) {
|
||||
const [activeTab, setActiveTab] = useState<'space' | 'integrations' | 'webhooks'>('space')
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null)
|
||||
|
||||
@@ -283,7 +221,7 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
|
||||
<div className="flex-1 p-4 md:p-6">
|
||||
{/* Tabs */}
|
||||
<div className="bg-card border-b border-border flex gap-4 md:gap-6 px-2 mb-6 rounded-t overflow-x-auto">
|
||||
{(['space', 'roles', 'tiers', 'invites', 'onboarding', 'integrations', 'webhooks'] as const).map(tab => (
|
||||
{(['space', 'integrations', 'webhooks'] as const).map(tab => (
|
||||
<button
|
||||
key={tab}
|
||||
onClick={() => setActiveTab(tab)}
|
||||
@@ -291,7 +229,7 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
|
||||
activeTab === tab ? 'border-primary text-primary' : 'border-transparent text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
{tab === 'roles' ? 'Users & Roles' : tab.charAt(0).toUpperCase() + tab.slice(1)}
|
||||
{tab.charAt(0).toUpperCase() + tab.slice(1)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
@@ -488,198 +426,6 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Areas (still under Space tab) */}
|
||||
{activeTab === 'space' && (
|
||||
<div className="bg-card rounded border border-border p-6 mt-6">
|
||||
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase mb-1">Areas</p>
|
||||
<p className="font-mono text-[10px] text-muted-foreground mb-6">
|
||||
Areas appear in the Tasks, Projects, and KB dropdowns. Defaults are seeded when a space
|
||||
is created. Rename, reorder, or archive freely; existing tasks tagged with the old
|
||||
name will not auto-rename.
|
||||
</p>
|
||||
|
||||
<ul className="divide-y divide-border mb-6">
|
||||
{areas.length === 0 ? (
|
||||
<li className="py-3 font-sans text-sm text-muted-foreground">No areas yet.</li>
|
||||
) : (
|
||||
areas.map(area => (
|
||||
<li key={area.id} className="py-2 flex items-center gap-3">
|
||||
<input
|
||||
type="number"
|
||||
value={area.sort_order}
|
||||
onChange={async e => {
|
||||
const next = parseInt(e.target.value || '0', 10)
|
||||
setAreas(prev => prev.map(a => (a.id === area.id ? { ...a, sort_order: next } : a)))
|
||||
}}
|
||||
onBlur={async e => {
|
||||
if (!isAdmin) return
|
||||
const next = parseInt(e.target.value || '0', 10)
|
||||
await updateArea({ areaId: area.id, sort_order: next })
|
||||
}}
|
||||
disabled={!isAdmin}
|
||||
className="w-14 bg-background border border-border rounded px-2 py-1 font-mono text-xs text-foreground disabled:opacity-50 focus:outline-none focus:border-primary"
|
||||
aria-label="Sort order"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
value={area.name}
|
||||
onChange={e => {
|
||||
const next = e.target.value
|
||||
setAreas(prev => prev.map(a => (a.id === area.id ? { ...a, name: next } : a)))
|
||||
}}
|
||||
onBlur={async e => {
|
||||
if (!isAdmin) return
|
||||
const next = e.target.value.trim()
|
||||
if (!next || next === area.name) return
|
||||
const result = await updateArea({ areaId: area.id, name: next })
|
||||
if ('error' in result && result.error) {
|
||||
setMessage({ type: 'error', text: result.error })
|
||||
}
|
||||
}}
|
||||
disabled={!isAdmin}
|
||||
maxLength={80}
|
||||
className={`flex-1 bg-background border border-border rounded px-3 py-1.5 font-sans text-sm rounded ${
|
||||
area.is_archived ? 'text-muted-foreground line-through' : 'text-foreground'
|
||||
} disabled:opacity-50 focus:outline-none focus:border-primary`}
|
||||
/>
|
||||
<span className="font-mono text-[10px] text-muted-foreground/60 w-24 truncate" title={area.code}>
|
||||
{area.code}
|
||||
</span>
|
||||
{isAdmin && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={async () => {
|
||||
const result = await updateArea({ areaId: area.id, is_archived: !area.is_archived })
|
||||
if ('error' in result && result.error) {
|
||||
setMessage({ type: 'error', text: result.error })
|
||||
} else {
|
||||
setAreas(prev =>
|
||||
prev.map(a =>
|
||||
a.id === area.id ? { ...a, is_archived: !a.is_archived } : a,
|
||||
),
|
||||
)
|
||||
}
|
||||
}}
|
||||
className="font-mono text-[10px] tracking-widest uppercase border border-border text-muted-foreground hover:text-foreground rounded px-2 py-1"
|
||||
>
|
||||
{area.is_archived ? 'restore' : 'archive'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={async () => {
|
||||
if (!confirm(`Delete area "${area.name}" entirely? Existing tagged items keep the name as plain text. Use Archive instead if it has been used.`)) return
|
||||
const result = await deleteArea(area.id)
|
||||
if ('error' in result && result.error) {
|
||||
setMessage({ type: 'error', text: result.error })
|
||||
} else {
|
||||
setAreas(prev => prev.filter(a => a.id !== area.id))
|
||||
}
|
||||
}}
|
||||
className="font-mono text-[10px] tracking-widest uppercase border border-border text-muted-foreground hover:text-red-500 hover:border-red-500 rounded px-2 py-1"
|
||||
>
|
||||
delete
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
))
|
||||
)}
|
||||
</ul>
|
||||
|
||||
{isAdmin && (
|
||||
<form
|
||||
onSubmit={async e => {
|
||||
e.preventDefault()
|
||||
const code = newArea.code.trim().toLowerCase()
|
||||
const name = newArea.name.trim()
|
||||
if (!code || !name) return
|
||||
setSaving(true)
|
||||
const result = await createArea({ code, name })
|
||||
if ('error' in result && result.error) {
|
||||
setMessage({ type: 'error', text: result.error })
|
||||
} else if ('data' in result && result.data) {
|
||||
setAreas(prev =>
|
||||
[...prev, result.data as Area].sort(
|
||||
(a, b) => a.sort_order - b.sort_order || a.name.localeCompare(b.name),
|
||||
),
|
||||
)
|
||||
setNewArea({ code: '', name: '' })
|
||||
}
|
||||
setSaving(false)
|
||||
}}
|
||||
className="border-t border-border pt-4 grid grid-cols-1 sm:grid-cols-[1fr_2fr_auto] gap-3 items-end"
|
||||
>
|
||||
<div>
|
||||
<label className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase block mb-1">
|
||||
Code
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={newArea.code}
|
||||
onChange={e =>
|
||||
setNewArea(f => ({
|
||||
...f,
|
||||
code: e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ''),
|
||||
}))
|
||||
}
|
||||
maxLength={40}
|
||||
placeholder="leather"
|
||||
className="w-full bg-background border border-border rounded px-3 py-2 font-mono text-sm text-foreground focus:outline-none focus:border-primary"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase block mb-1">
|
||||
Display name
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={newArea.name}
|
||||
onChange={e => setNewArea(f => ({ ...f, name: e.target.value }))}
|
||||
maxLength={80}
|
||||
placeholder="Leatherwork"
|
||||
className="w-full bg-background border border-border rounded px-3 py-2 font-sans text-sm text-foreground focus:outline-none focus:border-primary"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={saving || !newArea.code.trim() || !newArea.name.trim()}
|
||||
className="bg-primary text-white font-sans text-sm px-4 py-2 rounded hover:bg-primary/90 transition disabled:opacity-50"
|
||||
>
|
||||
Add area
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Users & Roles Tab */}
|
||||
{activeTab === 'roles' && (
|
||||
<div className="bg-card rounded border border-border p-6">
|
||||
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase mb-6">Roles & Permissions</p>
|
||||
|
||||
<div className="space-y-4">
|
||||
{ROLES_INFO.map(role => (
|
||||
<div key={role.name} className="flex items-start gap-4 py-3 border-b border-border last:border-0">
|
||||
<div className="flex-1">
|
||||
<p className={`font-sans text-sm font-medium ${role.color}`}>{role.name}</p>
|
||||
<p className="font-sans text-xs text-muted-foreground mt-0.5">{role.description}</p>
|
||||
</div>
|
||||
{role.permissions.length > 0 && (
|
||||
<div className="flex gap-1.5">
|
||||
{role.permissions.map(p => (
|
||||
<span key={p} className="font-mono text-[10px] px-2 py-0.5 rounded bg-primary/10 text-primary border border-primary/20">
|
||||
{p}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Integrations Tab */}
|
||||
{activeTab === 'integrations' && (
|
||||
<div className="bg-card rounded border border-border p-6">
|
||||
@@ -728,489 +474,6 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Tiers Tab */}
|
||||
{activeTab === 'tiers' && (
|
||||
<div className="bg-card rounded border border-border p-6">
|
||||
<div className="flex items-center justify-between mb-4 gap-3">
|
||||
<div>
|
||||
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase">Membership Tiers</p>
|
||||
<p className="font-sans text-sm text-muted-foreground mt-1">
|
||||
Customize tier names, prices, and billing cadence. Every space starts with the built-in plus, basic, and associate tiers.
|
||||
</p>
|
||||
</div>
|
||||
{isAdmin && (
|
||||
<button
|
||||
onClick={() => setShowNewTier(v => !v)}
|
||||
className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition flex items-center gap-1 whitespace-nowrap"
|
||||
>
|
||||
{showNewTier ? 'Cancel' : '+ New tier'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{showNewTier && (
|
||||
<form
|
||||
onSubmit={async e => {
|
||||
e.preventDefault()
|
||||
const cents = Math.round(parseFloat(String(newTier.monthly_price_cents) || '0') * 100)
|
||||
const result = await createTier({
|
||||
slug: newTier.slug.trim().toLowerCase(),
|
||||
name: newTier.name.trim(),
|
||||
description: newTier.description.trim() || undefined,
|
||||
monthly_price_cents: isNaN(cents) ? 0 : cents,
|
||||
billing_cadence: newTier.billing_cadence,
|
||||
})
|
||||
if ('error' in result && result.error) { toast.error(result.error); return }
|
||||
toast.success('Tier created')
|
||||
setShowNewTier(false)
|
||||
setNewTier({ slug: '', name: '', description: '', monthly_price_cents: 0, billing_cadence: 'monthly' })
|
||||
setTiers(prev => [...prev, {
|
||||
id: (result as { id: string }).id,
|
||||
slug: newTier.slug.trim().toLowerCase(),
|
||||
name: newTier.name.trim(),
|
||||
description: newTier.description.trim() || null,
|
||||
monthly_price_cents: isNaN(cents) ? 0 : cents,
|
||||
billing_cadence: newTier.billing_cadence,
|
||||
is_system: false,
|
||||
is_archived: false,
|
||||
sort_order: 100,
|
||||
}])
|
||||
}}
|
||||
className="mb-4 p-4 border border-border rounded bg-background grid grid-cols-1 md:grid-cols-2 gap-3"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
value={newTier.slug}
|
||||
onChange={e => setNewTier({ ...newTier, slug: e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, '-') })}
|
||||
placeholder="slug (lowercase)"
|
||||
maxLength={50}
|
||||
required
|
||||
className="bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
value={newTier.name}
|
||||
onChange={e => setNewTier({ ...newTier, name: e.target.value })}
|
||||
placeholder="Display name"
|
||||
maxLength={100}
|
||||
required
|
||||
className="bg-background border border-border text-foreground font-sans text-sm rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
value={newTier.monthly_price_cents as unknown as string}
|
||||
onChange={e => setNewTier({ ...newTier, monthly_price_cents: parseFloat(e.target.value || '0') as unknown as number })}
|
||||
placeholder="Price in dollars"
|
||||
className="bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<select
|
||||
value={newTier.billing_cadence}
|
||||
onChange={e => setNewTier({ ...newTier, billing_cadence: e.target.value as typeof newTier.billing_cadence })}
|
||||
className="bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
>
|
||||
<option value="monthly">Monthly</option>
|
||||
<option value="quarterly">Quarterly</option>
|
||||
<option value="annual">Annual</option>
|
||||
<option value="one_time">One time</option>
|
||||
<option value="custom">Custom</option>
|
||||
</select>
|
||||
<input
|
||||
type="text"
|
||||
value={newTier.description}
|
||||
onChange={e => setNewTier({ ...newTier, description: e.target.value })}
|
||||
placeholder="Description (optional)"
|
||||
maxLength={2000}
|
||||
className="md:col-span-2 bg-background border border-border text-foreground font-sans text-sm rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="md:col-span-2 bg-primary text-white text-xs font-sans px-3 py-1.5 rounded hover:bg-primary/90 transition"
|
||||
>
|
||||
Create tier
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<ul className="divide-y divide-border">
|
||||
{tiers.length === 0 && (
|
||||
<li className="py-6 text-center font-sans text-sm text-muted-foreground">No tiers yet.</li>
|
||||
)}
|
||||
{tiers.map(t => (
|
||||
<li key={t.id} className="py-3 flex items-center gap-3">
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-sans text-sm font-medium text-foreground">{t.name}</span>
|
||||
<span className="font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground">{t.slug}</span>
|
||||
{t.is_system && <span className="font-mono text-[10px] text-amber-600">built-in</span>}
|
||||
{t.is_archived && <span className="font-mono text-[10px] text-muted-foreground">archived</span>}
|
||||
</div>
|
||||
{t.description && <p className="font-sans text-xs text-muted-foreground mt-0.5">{t.description}</p>}
|
||||
<p className="font-mono text-[10px] text-muted-foreground/70 mt-0.5">
|
||||
${(t.monthly_price_cents / 100).toFixed(2)} / {t.billing_cadence.replace('_', ' ')}
|
||||
</p>
|
||||
</div>
|
||||
{isAdmin && (
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
defaultValue={(t.monthly_price_cents / 100).toFixed(2)}
|
||||
onBlur={async e => {
|
||||
const cents = Math.round(parseFloat(e.target.value || '0') * 100)
|
||||
if (cents === t.monthly_price_cents) return
|
||||
const result = await updateTier(t.id, { monthly_price_cents: cents })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setTiers(prev => prev.map(x => x.id === t.id ? { ...x, monthly_price_cents: cents } : x))
|
||||
toast.success('Price updated')
|
||||
}}
|
||||
className="w-24 bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
{!t.is_system && (
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (!confirm(`Delete tier "${t.name}"?`)) return
|
||||
const result = await deleteTier(t.id)
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setTiers(prev => prev.filter(x => x.id !== t.id))
|
||||
toast.success('Tier deleted')
|
||||
}}
|
||||
className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-red-500 hover:text-red-500 transition"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
)}
|
||||
{t.is_system && (
|
||||
<button
|
||||
onClick={async () => {
|
||||
const result = await updateTier(t.id, { is_archived: !t.is_archived })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setTiers(prev => prev.map(x => x.id === t.id ? { ...x, is_archived: !x.is_archived } : x))
|
||||
}}
|
||||
className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-primary hover:text-primary transition"
|
||||
>
|
||||
{t.is_archived ? 'Restore' : 'Archive'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Invites Tab */}
|
||||
{activeTab === 'invites' && (
|
||||
<div className="bg-card rounded border border-border p-6">
|
||||
<div className="flex items-center justify-between mb-4 gap-3">
|
||||
<div>
|
||||
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase">Invite Codes</p>
|
||||
<p className="font-sans text-sm text-muted-foreground mt-1">
|
||||
Generate codes for new members to join this space. Set an expiry, a max-use cap, or leave both blank for a permanent code. Toggle off to revoke.
|
||||
</p>
|
||||
</div>
|
||||
{isAdmin && (
|
||||
<button
|
||||
onClick={() => setShowNewInvite(v => !v)}
|
||||
className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition flex items-center gap-1 whitespace-nowrap"
|
||||
>
|
||||
{showNewInvite ? 'Cancel' : '+ New invite'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{showNewInvite && (
|
||||
<form
|
||||
onSubmit={async e => {
|
||||
e.preventDefault()
|
||||
const result = await createInvite({
|
||||
code: newInvite.code.trim().toUpperCase() || undefined,
|
||||
label: newInvite.label.trim() || undefined,
|
||||
expires_at: newInvite.expires_at || undefined,
|
||||
max_uses: newInvite.max_uses ? Number(newInvite.max_uses) : undefined,
|
||||
})
|
||||
if ('error' in result && result.error) { toast.error(result.error); return }
|
||||
const created = result as { id: string; code: string }
|
||||
toast.success(`Invite created: ${created.code}`)
|
||||
setShowNewInvite(false)
|
||||
setInvites(prev => [{
|
||||
id: created.id,
|
||||
code: created.code,
|
||||
label: newInvite.label.trim() || null,
|
||||
expires_at: newInvite.expires_at || null,
|
||||
max_uses: newInvite.max_uses ? Number(newInvite.max_uses) : null,
|
||||
uses_count: 0,
|
||||
is_enabled: true,
|
||||
created_at: new Date().toISOString(),
|
||||
}, ...prev])
|
||||
setNewInvite({ code: '', label: '', expires_at: '', max_uses: '' })
|
||||
}}
|
||||
className="mb-4 p-4 border border-border rounded bg-background grid grid-cols-1 md:grid-cols-2 gap-3"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
value={newInvite.code}
|
||||
onChange={e => setNewInvite({ ...newInvite, code: e.target.value.toUpperCase().replace(/[^A-Z0-9-]/g, '') })}
|
||||
placeholder="CODE (blank = auto-generate)"
|
||||
maxLength={32}
|
||||
className="bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
value={newInvite.label}
|
||||
onChange={e => setNewInvite({ ...newInvite, label: e.target.value })}
|
||||
placeholder="Label (e.g., open house 2026)"
|
||||
maxLength={100}
|
||||
className="bg-background border border-border text-foreground font-sans text-sm rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={newInvite.expires_at}
|
||||
onChange={e => setNewInvite({ ...newInvite, expires_at: e.target.value })}
|
||||
className="bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
value={newInvite.max_uses}
|
||||
onChange={e => setNewInvite({ ...newInvite, max_uses: e.target.value })}
|
||||
placeholder="Max uses (blank = unlimited)"
|
||||
className="bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1.5 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="md:col-span-2 bg-primary text-white text-xs font-sans px-3 py-1.5 rounded hover:bg-primary/90 transition"
|
||||
>
|
||||
Create invite
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<ul className="divide-y divide-border">
|
||||
{invites.length === 0 && (
|
||||
<li className="py-6 text-center font-sans text-sm text-muted-foreground">No invites yet.</li>
|
||||
)}
|
||||
{invites.map(inv => {
|
||||
const expired = inv.expires_at ? new Date(inv.expires_at) < new Date() : false
|
||||
const usedUp = inv.max_uses !== null && inv.uses_count >= inv.max_uses
|
||||
return (
|
||||
<li key={inv.id} className="py-3 flex items-center gap-3 flex-wrap">
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<code className="font-mono text-sm font-semibold text-primary bg-primary/10 px-2 py-0.5 rounded">{inv.code}</code>
|
||||
{inv.label && <span className="font-sans text-sm text-foreground">{inv.label}</span>}
|
||||
{!inv.is_enabled && <span className="font-mono text-[10px] text-red-500">disabled</span>}
|
||||
{expired && <span className="font-mono text-[10px] text-red-500">expired</span>}
|
||||
{usedUp && <span className="font-mono text-[10px] text-red-500">at cap</span>}
|
||||
</div>
|
||||
<p className="font-mono text-[10px] text-muted-foreground/70 mt-0.5">
|
||||
{inv.expires_at ? `expires ${new Date(inv.expires_at).toLocaleString()}` : 'permanent'}
|
||||
{' · '}
|
||||
uses {inv.uses_count}{inv.max_uses ? ` / ${inv.max_uses}` : ' (unlimited)'}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => { navigator.clipboard.writeText(inv.code); toast.success('Copied') }}
|
||||
className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-primary hover:text-primary transition"
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
{isAdmin && (
|
||||
<>
|
||||
<button
|
||||
onClick={async () => {
|
||||
const result = await updateInvite(inv.id, { is_enabled: !inv.is_enabled })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setInvites(prev => prev.map(x => x.id === inv.id ? { ...x, is_enabled: !x.is_enabled } : x))
|
||||
}}
|
||||
className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-primary hover:text-primary transition"
|
||||
>
|
||||
{inv.is_enabled ? 'Disable' : 'Enable'}
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (!confirm(`Delete invite "${inv.code}"?`)) return
|
||||
const result = await deleteInvite(inv.id)
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setInvites(prev => prev.filter(x => x.id !== inv.id))
|
||||
toast.success('Invite deleted')
|
||||
}}
|
||||
className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-red-500 hover:text-red-500 transition"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Onboarding Tab */}
|
||||
{activeTab === 'onboarding' && (
|
||||
<div className="bg-card rounded border border-border p-6">
|
||||
<div className="flex items-center justify-between mb-4 gap-3">
|
||||
<div>
|
||||
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase">New member onboarding</p>
|
||||
<p className="font-sans text-sm text-muted-foreground mt-1">
|
||||
These steps run, in order, the first time a new member opens the app. Reorder with the sort number. Disable a step to hide it. Built-in steps cannot be deleted, only disabled. Body text supports markdown and a safe subset of HTML.
|
||||
</p>
|
||||
</div>
|
||||
{isAdmin && (
|
||||
<button
|
||||
onClick={async () => {
|
||||
const result = await createOnboardingStep({
|
||||
step_type: 'content',
|
||||
title: 'New step',
|
||||
body: 'Edit this content in Settings, Onboarding.',
|
||||
sort_order: (onboardingSteps.reduce((m, s) => Math.max(m, s.sort_order), 0) + 1),
|
||||
})
|
||||
if ('error' in result && result.error) { toast.error(result.error); return }
|
||||
toast.success('Step added. Edit it below.')
|
||||
setOnboardingSteps(prev => [...prev, {
|
||||
id: (result as { id: string }).id,
|
||||
step_key: `custom-${(result as { id: string }).id.slice(0, 12)}`,
|
||||
step_type: 'content',
|
||||
title: 'New step',
|
||||
body: 'Edit this content in Settings, Onboarding.',
|
||||
config: {},
|
||||
is_enabled: true,
|
||||
is_required: false,
|
||||
is_system: false,
|
||||
sort_order: (onboardingSteps.reduce((m, s) => Math.max(m, s.sort_order), 0) + 1),
|
||||
}])
|
||||
}}
|
||||
className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition whitespace-nowrap"
|
||||
>
|
||||
+ Custom step
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ul className="space-y-3">
|
||||
{[...onboardingSteps].sort((a, b) => a.sort_order - b.sort_order).map(s => (
|
||||
<li key={s.id} className="border border-border rounded p-4">
|
||||
<div className="flex items-center gap-3 mb-3 flex-wrap">
|
||||
<input
|
||||
type="number"
|
||||
defaultValue={s.sort_order}
|
||||
disabled={!isAdmin}
|
||||
onBlur={async e => {
|
||||
const next = parseInt(e.target.value, 10)
|
||||
if (isNaN(next) || next === s.sort_order) return
|
||||
const result = await updateOnboardingStep(s.id, { sort_order: next })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.map(x => x.id === s.id ? { ...x, sort_order: next } : x))
|
||||
}}
|
||||
className="w-14 bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-1 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
<span className="font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground uppercase">{s.step_type.replace(/_/g, ' ')}</span>
|
||||
<input
|
||||
type="text"
|
||||
defaultValue={s.title}
|
||||
disabled={!isAdmin}
|
||||
onBlur={async e => {
|
||||
const next = e.target.value.trim()
|
||||
if (!next || next === s.title) return
|
||||
const result = await updateOnboardingStep(s.id, { title: next })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.map(x => x.id === s.id ? { ...x, title: next } : x))
|
||||
}}
|
||||
className="flex-1 min-w-[160px] bg-background border border-border text-foreground font-sans text-sm rounded px-2 py-1 focus:outline-none focus:border-primary"
|
||||
/>
|
||||
{s.is_system && <span className="font-mono text-[10px] text-amber-600">built-in</span>}
|
||||
</div>
|
||||
|
||||
{(s.step_type === 'welcome' || s.step_type === 'code_of_conduct' || s.step_type === 'payment' || s.step_type === 'content') && (
|
||||
<textarea
|
||||
defaultValue={s.body ?? ''}
|
||||
disabled={!isAdmin}
|
||||
rows={4}
|
||||
maxLength={50000}
|
||||
onBlur={async e => {
|
||||
const next = e.target.value
|
||||
if (next === (s.body ?? '')) return
|
||||
const result = await updateOnboardingStep(s.id, { body: next })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.map(x => x.id === s.id ? { ...x, body: next } : x))
|
||||
}}
|
||||
placeholder="Markdown / safe HTML. For payment steps, describe how to pay."
|
||||
className="w-full bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-2 focus:outline-none focus:border-primary mb-3"
|
||||
/>
|
||||
)}
|
||||
|
||||
{s.step_type === 'payment' && (
|
||||
<input
|
||||
type="url"
|
||||
defaultValue={(s.config?.payment_url as string) ?? ''}
|
||||
disabled={!isAdmin}
|
||||
placeholder="Payment link (https://...)"
|
||||
onBlur={async e => {
|
||||
const next = e.target.value.trim()
|
||||
if (next === ((s.config?.payment_url as string) ?? '')) return
|
||||
const result = await updateOnboardingStep(s.id, { config: { ...s.config, payment_url: next } })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.map(x => x.id === s.id ? { ...x, config: { ...x.config, payment_url: next } } : x))
|
||||
}}
|
||||
className="w-full bg-background border border-border text-foreground font-mono text-xs rounded px-2 py-2 focus:outline-none focus:border-primary mb-3"
|
||||
/>
|
||||
)}
|
||||
|
||||
{isAdmin && (
|
||||
<div className="flex items-center gap-4 flex-wrap">
|
||||
<label className="flex items-center gap-1.5 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={s.is_enabled}
|
||||
onChange={async e => {
|
||||
const result = await updateOnboardingStep(s.id, { is_enabled: e.target.checked })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.map(x => x.id === s.id ? { ...x, is_enabled: e.target.checked } : x))
|
||||
}}
|
||||
/>
|
||||
<span className="font-mono text-[10px] text-muted-foreground uppercase tracking-widest">Enabled</span>
|
||||
</label>
|
||||
<label className="flex items-center gap-1.5 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={s.is_required}
|
||||
onChange={async e => {
|
||||
const result = await updateOnboardingStep(s.id, { is_required: e.target.checked })
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.map(x => x.id === s.id ? { ...x, is_required: e.target.checked } : x))
|
||||
}}
|
||||
/>
|
||||
<span className="font-mono text-[10px] text-muted-foreground uppercase tracking-widest">Required</span>
|
||||
</label>
|
||||
{!s.is_system && (
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (!confirm(`Delete step "${s.title}"?`)) return
|
||||
const result = await deleteOnboardingStep(s.id)
|
||||
if (result.error) { toast.error(result.error); return }
|
||||
setOnboardingSteps(prev => prev.filter(x => x.id !== s.id))
|
||||
toast.success('Step deleted')
|
||||
}}
|
||||
className="ml-auto font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-red-500 hover:text-red-500 transition"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Webhooks Tab */}
|
||||
{activeTab === 'webhooks' && (
|
||||
<div className="bg-card rounded border border-border p-6 space-y-6">
|
||||
@@ -1300,15 +563,6 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right sidebar - Roles panel (visible on roles tab) */}
|
||||
{activeTab === 'roles' && (
|
||||
<div className="w-80 border-l border-border p-6 bg-card/50">
|
||||
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase mb-4">Role Assignment</p>
|
||||
<p className="font-sans text-sm text-muted-foreground">
|
||||
Member roles can be changed from the Members page. Only admins can change roles.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Integration Config Modal */}
|
||||
|
||||
Reference in New Issue
Block a user