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:
Moheeb Zara
2026-05-15 16:03:52 -07:00
parent 30bba045f8
commit 71d5e243cf
21 changed files with 791 additions and 856 deletions
+9
View File
@@ -5,6 +5,15 @@ All notable changes to this project are documented here. Format follows [Keep a
## [Unreleased] ## [Unreleased]
### Added ### Added
- **Customize hub** at `/customize` (admin/board): a dedicated home for per-space customization with a section rail (Roles, Membership tiers, Areas, Invite codes, Onboarding), split into one focused module per panel. Replaces the overloaded Settings tab strip.
- **Roles editor**: rename and recolor the five built-in roles, and create/edit/delete custom org-structure roles. Renamed roles now display (sidebar user card; helper `lib/role-labels.ts`).
- **Invite share links**: copy a one-click `/signup?invite=CODE` link in addition to the bare code; the signup page prefills the code and preselects join mode from `?invite=`.
### Changed
- Brand mark reverted to the terminal `>_` glyph (`components/brand-mark.tsx`) across the landing nav/footer, onboarding header, and favicon. `AtlasLogo` remains only on the resources project page.
- Settings slimmed to Space, Integrations, and Webhooks. Roles, Tiers, Areas, Invites, and Onboarding moved to `/customize`.
### Added (continued)
- **Configurable member onboarding**: a new member who joins via invite code is walked through an admin-defined sequence of steps at `/onboarding` before reaching the app. Built-in step types: welcome, code of conduct (required acknowledgement), profile, dues/payment nudge. Admins can add custom content steps with sanitized markdown/HTML, reorder, enable/disable, and mark steps required from Settings -> Onboarding. Founders skip the member flow (their onboarding is space configuration). Existing members were backfilled as completed so nobody is trapped. Server-side enforcement of required steps. New tables: `space_onboarding_steps`; new columns `space_members.onboarding_completed_at` and `onboarding_progress`. - **Configurable member onboarding**: a new member who joins via invite code is walked through an admin-defined sequence of steps at `/onboarding` before reaching the app. Built-in step types: welcome, code of conduct (required acknowledgement), profile, dues/payment nudge. Admins can add custom content steps with sanitized markdown/HTML, reorder, enable/disable, and mark steps required from Settings -> Onboarding. Founders skip the member flow (their onboarding is space configuration). Existing members were backfilled as completed so nobody is trapped. Server-side enforcement of required steps. New tables: `space_onboarding_steps`; new columns `space_members.onboarding_completed_at` and `onboarding_progress`.
- `SafeMarkdown` component (react-markdown + remark-gfm + rehype-raw + rehype-sanitize) for rendering admin-authored markdown/HTML without XSS. - `SafeMarkdown` component (react-markdown + remark-gfm + rehype-raw + rehype-sanitize) for rendering admin-authored markdown/HTML without XSS.
- `docs/UX_AND_PERSONAS.md`: persona model and the UX audit that drove onboarding. - `docs/UX_AND_PERSONAS.md`: persona model and the UX audit that drove onboarding.
+68
View File
@@ -0,0 +1,68 @@
'use client'
import { useState } from 'react'
import { RolesPanel } from './panels/roles-panel'
import { TiersPanel } from './panels/tiers-panel'
import { AreasPanel } from './panels/areas-panel'
import { InvitesPanel } from './panels/invites-panel'
import { OnboardingPanel } from './panels/onboarding-panel'
import type { RoleLabelRow, CustomRole, Tier, Invite, Step, Area } from './panels/types'
type Section = 'roles' | 'tiers' | 'areas' | 'invites' | 'onboarding'
const SECTIONS: { key: Section; label: string }[] = [
{ key: 'roles', label: 'Roles' },
{ key: 'tiers', label: 'Membership tiers' },
{ key: 'areas', label: 'Areas' },
{ key: 'invites', label: 'Invite codes' },
{ key: 'onboarding', label: 'Onboarding' },
]
interface Props {
isAdmin: boolean
roleLabels: RoleLabelRow[]
customRoles: CustomRole[]
tiers: Tier[]
invites: Invite[]
onboardingSteps: Step[]
areas: Area[]
}
export function CustomizeClient(props: Props) {
const [section, setSection] = useState<Section>('roles')
return (
<div className="p-4 md:p-6 max-w-6xl">
<div className="mb-6">
<h1 className="font-mono text-sm tracking-widest uppercase text-muted-foreground mb-1">Customize</h1>
<p className="font-sans text-sm text-muted-foreground">
Make the space yours. Operational settings (identity, integrations, webhooks) live under Settings.
</p>
</div>
<div className="flex flex-col md:flex-row gap-6">
<nav className="md:w-56 shrink-0 flex md:flex-col gap-1 overflow-x-auto md:overflow-visible">
{SECTIONS.map(s => (
<button
key={s.key}
onClick={() => setSection(s.key)}
className={`text-left px-3 py-2 rounded text-sm font-sans transition whitespace-nowrap ${
section === s.key ? 'bg-primary/10 text-primary' : 'text-foreground/70 hover:bg-muted hover:text-foreground'
}`}
>
{s.label}
</button>
))}
</nav>
<div className="flex-1 min-w-0">
{section === 'roles' && <RolesPanel isAdmin={props.isAdmin} roleLabels={props.roleLabels} customRoles={props.customRoles} />}
{section === 'tiers' && <TiersPanel isAdmin={props.isAdmin} tiers={props.tiers} />}
{section === 'areas' && <AreasPanel isAdmin={props.isAdmin} areas={props.areas} />}
{section === 'invites' && <InvitesPanel isAdmin={props.isAdmin} invites={props.invites} />}
{section === 'onboarding' && <OnboardingPanel isAdmin={props.isAdmin} steps={props.onboardingSteps} />}
</div>
</div>
</div>
)
}
+51
View File
@@ -0,0 +1,51 @@
import { redirect } from 'next/navigation'
import { createClient } from '@/lib/supabase/server'
import { CustomizeClient } from './customize-client'
export const dynamic = 'force-dynamic'
export default async function CustomizePage() {
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')
const isAdmin = member.role === 'admin'
const canCustomize = member.role === 'admin' || member.role === 'board'
if (!canCustomize) redirect('/dashboard')
const [
{ data: roleLabels },
{ data: customRoles },
{ data: tiers },
{ data: invites },
{ data: onboardingSteps },
{ data: areas },
] = await Promise.all([
supabase.from('space_role_labels').select('role, display_name, description, color').eq('space_id', member.space_id),
supabase.from('space_custom_roles').select('id, slug, name, description, color, sort_order').eq('space_id', member.space_id).order('sort_order'),
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'),
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 }),
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'),
supabase.from('space_areas').select('id, code, name, icon, sort_order, is_archived').eq('space_id', member.space_id).order('sort_order').order('name'),
])
return (
<CustomizeClient
isAdmin={isAdmin}
roleLabels={(roleLabels ?? []) as Array<{ role: string; display_name: string | null; description: string | null; color: string | null }>}
customRoles={(customRoles ?? []) as Array<{ id: string; slug: string; name: string; description: string | null; color: string | null; sort_order: number }>}
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 }>}
areas={(areas ?? []) as Array<{ id: string; code: string; name: string; icon: string | null; sort_order: number; is_archived: boolean }>}
/>
)
}
@@ -0,0 +1,58 @@
'use client'
import { useState } from 'react'
import { toast } from 'sonner'
import { createArea, updateArea, deleteArea } from '@/lib/actions'
import { Card } from './card'
import type { Area } from './types'
export function AreasPanel({ isAdmin, areas: initial }: { isAdmin: boolean; areas: Area[] }) {
const [areas, setAreas] = useState<Area[]>(initial)
const [showNew, setShowNew] = useState(false)
const [d, setD] = useState({ code: '', name: '', icon: '' })
return (
<Card
title="Areas"
blurb="Shop areas tag tasks, projects, and knowledge base entries. Archive to hide from pickers without losing history."
action={isAdmin ? <button onClick={() => setShowNew(v => !v)} className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition whitespace-nowrap">{showNew ? 'Cancel' : '+ New area'}</button> : undefined}
>
{showNew && (
<form
onSubmit={async e => {
e.preventDefault()
const result = await createArea({ code: d.code.trim().toLowerCase(), name: d.name.trim(), icon: d.icon.trim() || undefined })
if ('error' in result && result.error) { toast.error(result.error); return }
toast.success('Area created')
const created = result as { data?: { id: string } }
setAreas(prev => [...prev, { id: created.data?.id ?? crypto.randomUUID(), code: d.code.trim().toLowerCase(), name: d.name.trim(), icon: d.icon.trim() || null, sort_order: 100, is_archived: false }])
setShowNew(false); setD({ code: '', name: '', icon: '' })
}}
className="mb-4 p-4 border border-border rounded bg-background grid grid-cols-1 md:grid-cols-3 gap-3"
>
<input type="text" required value={d.code} onChange={e => setD({ ...d, code: e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, '-') })} placeholder="code" 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" required value={d.name} onChange={e => setD({ ...d, name: e.target.value })} placeholder="Display name" 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="text" value={d.icon} onChange={e => setD({ ...d, icon: e.target.value })} placeholder="Icon (emoji, optional)" className="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-3 bg-primary text-white text-xs font-sans px-3 py-1.5 rounded hover:bg-primary/90 transition">Create area</button>
</form>
)}
<ul className="divide-y divide-border">
{areas.length === 0 && <li className="py-6 text-center font-sans text-sm text-muted-foreground">No areas yet.</li>}
{[...areas].sort((a, b) => a.sort_order - b.sort_order).map(a => (
<li key={a.id} className={`py-3 flex items-center gap-3 flex-wrap ${a.is_archived ? 'opacity-50' : ''}`}>
<input type="number" defaultValue={a.sort_order} disabled={!isAdmin} onBlur={async e => { const n = parseInt(e.target.value, 10); if (isNaN(n) || n === a.sort_order) return; const res = await updateArea({ areaId: a.id, sort_order: n }); if (res.error) { toast.error(res.error); return } setAreas(prev => prev.map(x => x.id === a.id ? { ...x, sort_order: n } : 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" />
{a.icon && <span>{a.icon}</span>}
<input type="text" defaultValue={a.name} disabled={!isAdmin} onBlur={async e => { const v = e.target.value.trim(); if (!v || v === a.name) return; const res = await updateArea({ areaId: a.id, name: v }); if (res.error) { toast.error(res.error); return } setAreas(prev => prev.map(x => x.id === a.id ? { ...x, name: v } : x)); toast.success('Saved') }} className="flex-1 min-w-[140px] bg-background border border-border text-foreground font-sans text-sm 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">{a.code}</span>
{isAdmin && (
<div className="flex items-center gap-1.5">
<button onClick={async () => { const res = await updateArea({ areaId: a.id, is_archived: !a.is_archived }); if (res.error) { toast.error(res.error); return } setAreas(prev => prev.map(x => x.id === a.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">{a.is_archived ? 'Restore' : 'Archive'}</button>
<button onClick={async () => { if (!confirm(`Delete area "${a.name}"?`)) return; const res = await deleteArea(a.id); if (res.error) { toast.error(res.error); return } setAreas(prev => prev.filter(x => x.id !== a.id)); toast.success('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>
</Card>
)
}
+25
View File
@@ -0,0 +1,25 @@
// Shared section card chrome for every Customize panel.
export function Card({
title,
blurb,
action,
children,
}: {
title: string
blurb: string
action?: React.ReactNode
children: React.ReactNode
}) {
return (
<div className="bg-card border border-border rounded p-6">
<div className="flex items-start justify-between gap-3 mb-4">
<div>
<p className="font-mono text-[10px] tracking-widest text-muted-foreground uppercase">{title}</p>
<p className="font-sans text-sm text-muted-foreground mt-1">{blurb}</p>
</div>
{action}
</div>
{children}
</div>
)
}
@@ -0,0 +1,78 @@
'use client'
import { useState } from 'react'
import { toast } from 'sonner'
import { createInvite, updateInvite, deleteInvite } from '@/lib/actions'
import { Card } from './card'
import type { Invite } from './types'
function inviteLink(code: string) {
const origin = typeof window !== 'undefined' ? window.location.origin : ''
return `${origin}/signup?invite=${encodeURIComponent(code)}`
}
export function InvitesPanel({ isAdmin, invites: initial }: { isAdmin: boolean; invites: Invite[] }) {
const [invites, setInvites] = useState<Invite[]>(initial)
const [showNew, setShowNew] = useState(false)
const [d, setD] = useState({ code: '', label: '', expires_at: '', max_uses: '' })
return (
<Card
title="Invite codes"
blurb="Generate codes for new members. Share the code or the one-click join link. Set an expiry, a max-use cap, or leave both blank for a permanent code. Disable to revoke."
action={isAdmin ? <button onClick={() => setShowNew(v => !v)} className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition whitespace-nowrap">{showNew ? 'Cancel' : '+ New invite'}</button> : undefined}
>
{showNew && (
<form
onSubmit={async e => {
e.preventDefault()
const result = await createInvite({ code: d.code.trim().toUpperCase() || undefined, label: d.label.trim() || undefined, expires_at: d.expires_at || undefined, max_uses: d.max_uses ? Number(d.max_uses) : undefined })
if ('error' in result && result.error) { toast.error(result.error); return }
const c = result as { id: string; code: string }
toast.success(`Invite created: ${c.code}`)
setInvites(prev => [{ id: c.id, code: c.code, label: d.label.trim() || null, expires_at: d.expires_at || null, max_uses: d.max_uses ? Number(d.max_uses) : null, uses_count: 0, is_enabled: true, created_at: new Date().toISOString() }, ...prev])
setShowNew(false); setD({ 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" maxLength={32} value={d.code} onChange={e => setD({ ...d, code: e.target.value.toUpperCase().replace(/[^A-Z0-9-]/g, '') })} placeholder="CODE (blank = auto)" 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" maxLength={100} value={d.label} onChange={e => setD({ ...d, label: e.target.value })} placeholder="Label (optional)" 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={d.expires_at} onChange={e => setD({ ...d, 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={d.max_uses} onChange={e => setD({ ...d, 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('Code copied') }} className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-primary hover:text-primary transition">Copy code</button>
<button onClick={() => { navigator.clipboard.writeText(inviteLink(inv.code)); toast.success('Invite link copied') }} className="font-mono text-[10px] border border-border px-2 py-1 rounded hover:border-primary hover:text-primary transition">Copy link</button>
{isAdmin && (
<>
<button onClick={async () => { const res = await updateInvite(inv.id, { is_enabled: !inv.is_enabled }); if (res.error) { toast.error(res.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 res = await deleteInvite(inv.id); if (res.error) { toast.error(res.error); return } setInvites(prev => prev.filter(x => x.id !== inv.id)); toast.success('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>
</Card>
)
}
@@ -0,0 +1,66 @@
'use client'
import { useState } from 'react'
import { toast } from 'sonner'
import { createOnboardingStep, updateOnboardingStep, deleteOnboardingStep } from '@/lib/actions'
import { Card } from './card'
import type { Step } from './types'
export function OnboardingPanel({ isAdmin, steps: initial }: { isAdmin: boolean; steps: Step[] }) {
const [steps, setSteps] = useState<Step[]>(initial)
return (
<Card
title="New member onboarding"
blurb="These steps run, in order, the first time a new member opens the app. Reorder with the number. Disable to hide. Built-in steps cannot be deleted, only disabled. Body supports markdown and a safe subset of HTML."
action={isAdmin ? (
<button
onClick={async () => {
const result = await createOnboardingStep({ step_type: 'content', title: 'New step', body: 'Edit this content in Customize, Onboarding.', sort_order: steps.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')
const id = (result as { id: string }).id
setSteps(prev => [...prev, { id, step_key: `custom-${id.slice(0, 12)}`, step_type: 'content', title: 'New step', body: 'Edit this content in Customize, Onboarding.', config: {}, is_enabled: true, is_required: false, is_system: false, sort_order: prev.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>
) : undefined}
>
<ul className="space-y-3">
{[...steps].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 n = parseInt(e.target.value, 10); if (isNaN(n) || n === s.sort_order) return; const res = await updateOnboardingStep(s.id, { sort_order: n }); if (res.error) { toast.error(res.error); return } setSteps(prev => prev.map(x => x.id === s.id ? { ...x, sort_order: n } : 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 v = e.target.value.trim(); if (!v || v === s.title) return; const res = await updateOnboardingStep(s.id, { title: v }); if (res.error) { toast.error(res.error); return } setSteps(prev => prev.map(x => x.id === s.id ? { ...x, title: v } : 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 v = e.target.value; if (v === (s.body ?? '')) return; const res = await updateOnboardingStep(s.id, { body: v }); if (res.error) { toast.error(res.error); return } setSteps(prev => prev.map(x => x.id === s.id ? { ...x, body: v } : x)) }} placeholder="Markdown / safe HTML" 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 v = e.target.value.trim(); if (v === ((s.config?.payment_url as string) ?? '')) return; const res = await updateOnboardingStep(s.id, { config: { ...s.config, payment_url: v } }); if (res.error) { toast.error(res.error); return } setSteps(prev => prev.map(x => x.id === s.id ? { ...x, config: { ...x.config, payment_url: v } } : 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 res = await updateOnboardingStep(s.id, { is_enabled: e.target.checked }); if (res.error) { toast.error(res.error); return } setSteps(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 res = await updateOnboardingStep(s.id, { is_required: e.target.checked }); if (res.error) { toast.error(res.error); return } setSteps(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 res = await deleteOnboardingStep(s.id); if (res.error) { toast.error(res.error); return } setSteps(prev => prev.filter(x => x.id !== s.id)); toast.success('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>
</Card>
)
}
+150
View File
@@ -0,0 +1,150 @@
'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { toast } from 'sonner'
import { upsertRoleLabel, createCustomRole, updateCustomRole, deleteCustomRole } from '@/lib/actions'
import { BUILTIN_ROLES, DEFAULT_ROLE_LABELS } from '@/lib/role-labels'
import { Card } from './card'
import type { RoleLabelRow, CustomRole } from './types'
export function RolesPanel({ isAdmin, roleLabels, customRoles: initial }: { isAdmin: boolean; roleLabels: RoleLabelRow[]; customRoles: CustomRole[] }) {
const router = useRouter()
const [customRoles, setCustomRoles] = useState<CustomRole[]>(initial)
const [showNew, setShowNew] = useState(false)
const [draft, setDraft] = useState({ slug: '', name: '', color: '#d4ff00', description: '' })
function labelFor(role: string) {
const row = roleLabels.find(r => r.role === role)
const def = DEFAULT_ROLE_LABELS[role as keyof typeof DEFAULT_ROLE_LABELS]
return {
name: row?.display_name ?? def?.name ?? role,
description: row?.description ?? '',
color: row?.color ?? def?.color ?? '#e5e7eb',
}
}
async function saveLabel(role: string, patch: { display_name?: string; description?: string; color?: string }) {
const cur = labelFor(role)
const result = await upsertRoleLabel({
role: role as 'admin' | 'board' | 'treasurer' | 'member' | 'associate',
display_name: patch.display_name ?? cur.name,
description: patch.description ?? cur.description,
color: patch.color ?? cur.color,
})
if (result.error) { toast.error(result.error); return }
toast.success('Role updated')
router.refresh()
}
return (
<div className="space-y-6">
<Card title="Built-in roles" blurb="The five permission roles are fixed, but you can rename and recolor them to match your space's vocabulary. The new label shows everywhere a role is displayed.">
<ul className="divide-y divide-border">
{BUILTIN_ROLES.map(role => {
const l = labelFor(role)
return (
<li key={role} className="py-3 flex items-center gap-3 flex-wrap">
<span className="font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground w-20 text-center">{role}</span>
<input
type="text"
defaultValue={l.name}
disabled={!isAdmin}
onBlur={e => { const v = e.target.value.trim(); if (v && v !== l.name) saveLabel(role, { display_name: v }) }}
className="bg-background border border-border text-foreground font-sans text-sm rounded px-2 py-1 focus:outline-none focus:border-primary"
/>
<input
type="color"
defaultValue={l.color}
disabled={!isAdmin}
onBlur={e => { if (e.target.value !== l.color) saveLabel(role, { color: e.target.value }) }}
className="w-9 h-8 bg-background border border-border rounded cursor-pointer"
title="Badge color"
/>
<input
type="text"
defaultValue={l.description}
disabled={!isAdmin}
placeholder="Short description (optional)"
onBlur={e => { if (e.target.value !== l.description) saveLabel(role, { description: e.target.value }) }}
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"
/>
</li>
)
})}
</ul>
</Card>
<Card
title="Custom roles"
blurb="Extra labels for org structure (committees, area leads, mentors). Display-only; they do not change permissions."
action={isAdmin ? (
<button onClick={() => setShowNew(v => !v)} className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition whitespace-nowrap">
{showNew ? 'Cancel' : '+ Custom role'}
</button>
) : undefined}
>
{showNew && (
<form
onSubmit={async e => {
e.preventDefault()
const result = await createCustomRole({
slug: draft.slug.trim().toLowerCase(),
name: draft.name.trim(),
color: draft.color,
description: draft.description.trim() || undefined,
})
if ('error' in result && result.error) { toast.error(result.error); return }
toast.success('Custom role created')
setCustomRoles(prev => [...prev, { id: (result as { id: string }).id, slug: draft.slug.trim().toLowerCase(), name: draft.name.trim(), color: draft.color, description: draft.description.trim() || null, sort_order: 100 }])
setShowNew(false)
setDraft({ slug: '', name: '', color: '#d4ff00', description: '' })
}}
className="mb-4 p-4 border border-border rounded bg-background grid grid-cols-1 md:grid-cols-2 gap-3"
>
<input type="text" required maxLength={50} value={draft.slug} onChange={e => setDraft({ ...draft, slug: e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, '-') })} placeholder="slug" 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" required maxLength={100} value={draft.name} onChange={e => setDraft({ ...draft, name: e.target.value })} placeholder="Display name" 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="color" value={draft.color} onChange={e => setDraft({ ...draft, color: e.target.value })} className="w-9 h-8 bg-background border border-border rounded cursor-pointer" />
<input type="text" maxLength={500} value={draft.description} onChange={e => setDraft({ ...draft, description: e.target.value })} placeholder="Description (optional)" className="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</button>
</form>
)}
{customRoles.length === 0 ? (
<p className="font-sans text-sm text-muted-foreground py-2">No custom roles yet.</p>
) : (
<ul className="divide-y divide-border">
{customRoles.map(r => (
<li key={r.id} className="py-3 flex items-center gap-3 flex-wrap">
<span className="w-3 h-3 rounded-full shrink-0" style={{ backgroundColor: r.color ?? '#888' }} />
<input
type="text"
defaultValue={r.name}
disabled={!isAdmin}
onBlur={async e => { const v = e.target.value.trim(); if (!v || v === r.name) return; const res = await updateCustomRole(r.id, { name: v }); if (res.error) { toast.error(res.error); return } setCustomRoles(prev => prev.map(x => x.id === r.id ? { ...x, name: v } : x)); toast.success('Saved') }}
className="bg-background border border-border text-foreground font-sans text-sm 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">{r.slug}</span>
<input
type="text"
defaultValue={r.description ?? ''}
disabled={!isAdmin}
placeholder="Description"
onBlur={async e => { const v = e.target.value; if (v === (r.description ?? '')) return; const res = await updateCustomRole(r.id, { description: v }); if (res.error) { toast.error(res.error); return } setCustomRoles(prev => prev.map(x => x.id === r.id ? { ...x, description: v } : x)) }}
className="flex-1 min-w-[140px] bg-background border border-border text-foreground font-sans text-sm rounded px-2 py-1 focus:outline-none focus:border-primary"
/>
{isAdmin && (
<button
onClick={async () => { if (!confirm(`Delete role "${r.name}"?`)) return; const res = await deleteCustomRole(r.id); if (res.error) { toast.error(res.error); return } setCustomRoles(prev => prev.filter(x => x.id !== r.id)); toast.success('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>
)}
</li>
))}
</ul>
)}
</Card>
</div>
)
}
@@ -0,0 +1,77 @@
'use client'
import { useState } from 'react'
import { toast } from 'sonner'
import { createTier, updateTier, deleteTier } from '@/lib/actions'
import { Card } from './card'
import type { Tier } from './types'
export function TiersPanel({ isAdmin, tiers: initial }: { isAdmin: boolean; tiers: Tier[] }) {
const [tiers, setTiers] = useState<Tier[]>(initial)
const [showNew, setShowNew] = useState(false)
const [d, setD] = useState({ slug: '', name: '', dollars: '0', cadence: 'monthly' as Tier['billing_cadence'], description: '' })
return (
<Card
title="Membership tiers"
blurb="Built-in plus/basic/associate seed every space. Add your own, set prices and cadence. Built-in tiers can be archived but not deleted."
action={isAdmin ? <button onClick={() => setShowNew(v => !v)} className="font-mono text-[10px] border border-border px-3 py-1.5 rounded hover:border-primary hover:text-primary transition whitespace-nowrap">{showNew ? 'Cancel' : '+ New tier'}</button> : undefined}
>
{showNew && (
<form
onSubmit={async e => {
e.preventDefault()
const cents = Math.round(parseFloat(d.dollars || '0') * 100)
const result = await createTier({ slug: d.slug.trim().toLowerCase(), name: d.name.trim(), description: d.description.trim() || undefined, monthly_price_cents: isNaN(cents) ? 0 : cents, billing_cadence: d.cadence })
if ('error' in result && result.error) { toast.error(result.error); return }
toast.success('Tier created')
setTiers(prev => [...prev, { id: (result as { id: string }).id, slug: d.slug.trim().toLowerCase(), name: d.name.trim(), description: d.description.trim() || null, monthly_price_cents: isNaN(cents) ? 0 : cents, billing_cadence: d.cadence, is_system: false, is_archived: false, sort_order: 100 }])
setShowNew(false); setD({ slug: '', name: '', dollars: '0', cadence: 'monthly', description: '' })
}}
className="mb-4 p-4 border border-border rounded bg-background grid grid-cols-1 md:grid-cols-2 gap-3"
>
<input type="text" required maxLength={50} value={d.slug} onChange={e => setD({ ...d, slug: e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, '-') })} placeholder="slug" 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" required maxLength={100} value={d.name} onChange={e => setD({ ...d, name: e.target.value })} placeholder="Display name" 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={d.dollars} onChange={e => setD({ ...d, dollars: e.target.value })} placeholder="Price (USD)" 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={d.cadence} onChange={e => setD({ ...d, cadence: e.target.value as Tier['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" maxLength={2000} value={d.description} onChange={e => setD({ ...d, description: e.target.value })} placeholder="Description (optional)" 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 flex-wrap">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 flex-wrap">
<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 res = await updateTier(t.id, { monthly_price_cents: cents }); if (res.error) { toast.error(res.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 () => { const res = await updateTier(t.id, { is_archived: !t.is_archived }); if (res.error) { toast.error(res.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>
) : (
<button onClick={async () => { if (!confirm(`Delete tier "${t.name}"?`)) return; const res = await deleteTier(t.id); if (res.error) { toast.error(res.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>
)}
</div>
)}
</li>
))}
</ul>
</Card>
)
}
+65
View File
@@ -0,0 +1,65 @@
// Shared shapes for the Customize hub panels. The DB tables are loosely typed
// in queries; these are the props contracts between the page and the panels.
export interface RoleLabelRow {
role: string
display_name: string | null
description: string | null
color: string | null
}
export interface CustomRole {
id: string
slug: string
name: string
description: string | null
color: string | null
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
}
export type OnboardingStepType = 'welcome' | 'code_of_conduct' | 'profile' | 'payment' | 'content'
export interface Step {
id: string
step_key: string
step_type: OnboardingStepType
title: string
body: string | null
config: Record<string, unknown>
is_enabled: boolean
is_required: boolean
is_system: boolean
sort_order: number
}
export interface Area {
id: string
code: string
name: string
icon: string | null
sort_order: number
is_archived: boolean
}
+5
View File
@@ -1,6 +1,7 @@
import { createClient } from '@/lib/supabase/server' import { createClient } from '@/lib/supabase/server'
import { redirect } from 'next/navigation' import { redirect } from 'next/navigation'
import { AppSidebar } from '@/components/app-sidebar' import { AppSidebar } from '@/components/app-sidebar'
import { getRoleLabelMap } from '@/lib/role-labels'
export default async function AppLayout({ children }: { children: React.ReactNode }) { export default async function AppLayout({ children }: { children: React.ReactNode }) {
const supabase = await createClient() const supabase = await createClient()
@@ -47,10 +48,14 @@ export default async function AppLayout({ children }: { children: React.ReactNod
.eq('space_id', member.space_id) .eq('space_id', member.space_id)
.eq('link_status', 'unlinked') .eq('link_status', 'unlinked')
const roleMap = await getRoleLabelMap(supabase, member.space_id)
const roleName = roleMap[member.role]?.name ?? member.role
return ( return (
<div className="flex h-screen bg-background overflow-hidden"> <div className="flex h-screen bg-background overflow-hidden">
<AppSidebar <AppSidebar
member={member} member={member}
roleName={roleName}
taskBadge={taskCount ?? 0} taskBadge={taskCount ?? 0}
paymentBadge={paymentCount ?? 0} paymentBadge={paymentCount ?? 0}
/> />
-66
View File
@@ -18,31 +18,6 @@ export default async function SettingsPage() {
const { data: integrations } = await supabase const { data: integrations } = await supabase
.from('integrations').select('*').eq('space_id', member.space_id) .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' const isAdmin = member?.role === 'admin'
return ( return (
@@ -51,47 +26,6 @@ export default async function SettingsPage() {
isAdmin={isAdmin} isAdmin={isAdmin}
integrations={integrations ?? []} integrations={integrations ?? []}
currentRole={member.role} 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
}>}
/> />
) )
} }
+7 -753
View File
@@ -6,74 +6,21 @@ import { updateSpaceSettings, saveIntegration, disconnectIntegration, rotateWebh
import { toast } from 'sonner' import { toast } from 'sonner'
import { financialVisibilities, directoryVisibilities } from '@/lib/validations' 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' import type { Tables } from '@/types/database'
type Space = Tables<'spaces'> type Space = Tables<'spaces'>
type Integration = Tables<'integrations'> 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 { interface Props {
space: Space space: Space
isAdmin: boolean isAdmin: boolean
integrations: Integration[] integrations: Integration[]
currentRole: string 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 = [ const INTEGRATIONS_CONFIG = [
{ {
platform: 'paypal', 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) { export default function SettingsClient({ space, isAdmin, integrations, currentRole }: Props) {
const [activeTab, setActiveTab] = useState<'space' | 'roles' | 'tiers' | 'invites' | 'onboarding' | 'integrations' | 'webhooks'>('space') const [activeTab, setActiveTab] = useState<'space' | '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: '' })
const [saving, setSaving] = useState(false) const [saving, setSaving] = useState(false)
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null) 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"> <div className="flex-1 p-4 md:p-6">
{/* Tabs */} {/* Tabs */}
<div className="bg-card border-b border-border flex gap-4 md:gap-6 px-2 mb-6 rounded-t overflow-x-auto"> <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 <button
key={tab} key={tab}
onClick={() => setActiveTab(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' 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> </button>
))} ))}
</div> </div>
@@ -488,198 +426,6 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
</div> </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 */} {/* Integrations Tab */}
{activeTab === 'integrations' && ( {activeTab === 'integrations' && (
<div className="bg-card rounded border border-border p-6"> <div className="bg-card rounded border border-border p-6">
@@ -728,489 +474,6 @@ export default function SettingsClient({ space, isAdmin, integrations, currentRo
</div> </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 */} {/* Webhooks Tab */}
{activeTab === 'webhooks' && ( {activeTab === 'webhooks' && (
<div className="bg-card rounded border border-border p-6 space-y-6"> <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> </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> </div>
{/* Integration Config Modal */} {/* Integration Config Modal */}
+3 -6
View File
@@ -2,7 +2,7 @@
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import Link from 'next/link' import Link from 'next/link'
import { AtlasLogo } from '@/components/resources/atlas-logo' import { BrandMark } from '@/components/brand-mark'
// Icons // Icons
function IcoUsers({ className }: { className?: string }) { function IcoUsers({ className }: { className?: string }) {
@@ -26,9 +26,6 @@ function IcoDoc({ className }: { className?: string }) {
function IcoArrow({ className }: { className?: string }) { function IcoArrow({ className }: { className?: string }) {
return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 8l4 4m0 0l-4 4m4-4H3" /></svg> return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 8l4 4m0 0l-4 4m4-4H3" /></svg>
} }
function IcoTerminal({ className }: { className?: string }) {
return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>
}
function IcoEye({ className }: { className?: string }) { function IcoEye({ className }: { className?: string }) {
return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" /></svg> return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" /></svg>
} }
@@ -319,7 +316,7 @@ export default function LandingPage() {
<nav className="border-b border-border bg-sidebar"> <nav className="border-b border-border bg-sidebar">
<div className="max-w-6xl mx-auto px-4 md:px-6 py-3 flex items-center justify-between gap-4"> <div className="max-w-6xl mx-auto px-4 md:px-6 py-3 flex items-center justify-between gap-4">
<div className="flex items-center gap-2 min-w-0"> <div className="flex items-center gap-2 min-w-0">
<AtlasLogo className="w-6 h-6 text-primary shrink-0" /> <BrandMark className="w-5 h-5 text-primary shrink-0" />
<span className="font-mono text-sm font-bold text-white truncate">hackerspace.sh</span> <span className="font-mono text-sm font-bold text-white truncate">hackerspace.sh</span>
</div> </div>
<div className="flex items-center gap-2 shrink-0"> <div className="flex items-center gap-2 shrink-0">
@@ -516,7 +513,7 @@ export default function LandingPage() {
<div className="max-w-6xl mx-auto px-4 md:px-6 py-8"> <div className="max-w-6xl mx-auto px-4 md:px-6 py-8">
<div className="flex flex-col md:flex-row items-start md:items-center justify-between gap-4"> <div className="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<AtlasLogo className="w-5 h-5 text-primary" /> <BrandMark className="w-4 h-4 text-primary" />
<span className="font-mono text-xs text-sidebar-foreground">hackerspace.sh</span> <span className="font-mono text-xs text-sidebar-foreground">hackerspace.sh</span>
</div> </div>
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
+2 -2
View File
@@ -3,7 +3,7 @@
import { useState } from 'react' import { useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { toast } from 'sonner' import { toast } from 'sonner'
import { AtlasLogo } from '@/components/resources/atlas-logo' import { BrandMark } from '@/components/brand-mark'
import { SafeMarkdown } from '@/components/safe-markdown' import { SafeMarkdown } from '@/components/safe-markdown'
import { import {
markOnboardingStepDone, markOnboardingStepDone,
@@ -97,7 +97,7 @@ export function OnboardingFlow({ spaceName, steps, canSkip, profile: initialProf
return ( return (
<div className="min-h-screen bg-sidebar flex flex-col"> <div className="min-h-screen bg-sidebar flex flex-col">
<header className="px-4 md:px-6 py-4 flex items-center gap-2 border-b border-sidebar-border"> <header className="px-4 md:px-6 py-4 flex items-center gap-2 border-b border-sidebar-border">
<AtlasLogo className="w-6 h-6 text-primary" /> <BrandMark className="w-5 h-5 text-primary" />
<span className="font-mono text-sm font-bold text-white">{spaceName}</span> <span className="font-mono text-sm font-bold text-white">{spaceName}</span>
{canSkip && ( {canSkip && (
<button <button
+8
View File
@@ -33,6 +33,14 @@ export default function SignupPage() {
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
useEffect(() => { useEffect(() => {
// A shared invite link looks like /signup?invite=CODE. Prefill the code
// and preselect "join" so the recipient lands on the right form.
const params = new URLSearchParams(window.location.search)
const invite = params.get('invite')
if (invite) {
setInviteCode(invite.trim().toUpperCase())
setMode('join')
}
const checkAuth = async () => { const checkAuth = async () => {
const supabase = createClient() const supabase = createClient()
const { data: { user } } = await supabase.auth.getUser() const { data: { user } } = await supabase.auth.getUser()
+5 -3
View File
@@ -13,7 +13,7 @@ import {
Menu, X, LayoutDashboard, ListChecks, FolderKanban, Settings2, Menu, X, LayoutDashboard, ListChecks, FolderKanban, Settings2,
MessageSquare, Users, CreditCard, BookUser, Download, LogOut, MessageSquare, Users, CreditCard, BookUser, Download, LogOut,
Vote, ShieldAlert, ScrollText, LineChart, UserCircle, UserSearch, Vote, ShieldAlert, ScrollText, LineChart, UserCircle, UserSearch,
MessagesSquare, MessagesSquare, SlidersHorizontal,
} from 'lucide-react' } from 'lucide-react'
interface NavLinkProps { interface NavLinkProps {
@@ -52,12 +52,13 @@ function NavLink({ href, label, icon: Icon, badge, active, onClick }: NavLinkPro
interface AppSidebarProps { interface AppSidebarProps {
member: SpaceMember & { spaces: Space | null } member: SpaceMember & { spaces: Space | null }
roleName?: string
taskBadge?: number taskBadge?: number
commsBadge?: number commsBadge?: number
paymentBadge?: number paymentBadge?: number
} }
export function AppSidebar({ member, taskBadge = 0, commsBadge = 0, paymentBadge = 0 }: AppSidebarProps) { export function AppSidebar({ member, roleName, taskBadge = 0, commsBadge = 0, paymentBadge = 0 }: AppSidebarProps) {
const pathname = usePathname() const pathname = usePathname()
const space = member.spaces const space = member.spaces
const initials = (member.display_name || 'U').split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2) const initials = (member.display_name || 'U').split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2)
@@ -120,6 +121,7 @@ export function AppSidebar({ member, taskBadge = 0, commsBadge = 0, paymentBadge
<div className="px-3 mt-4 mb-1"> <div className="px-3 mt-4 mb-1">
<p className="text-[10px] uppercase tracking-widest text-[var(--sidebar-foreground)]/30 px-2 py-1 font-mono">Admin</p> <p className="text-[10px] uppercase tracking-widest text-[var(--sidebar-foreground)]/30 px-2 py-1 font-mono">Admin</p>
</div> </div>
<NavLink href="/customize" label="Customize" icon={SlidersHorizontal} active={isActive('/customize')} onClick={onNav} />
<NavLink href="/import" label="Import / Sync" icon={Download} active={isActive('/import')} onClick={onNav} /> <NavLink href="/import" label="Import / Sync" icon={Download} active={isActive('/import')} onClick={onNav} />
<NavLink href="/settings" label="Settings" icon={Settings2} active={isActive('/settings')} onClick={onNav} /> <NavLink href="/settings" label="Settings" icon={Settings2} active={isActive('/settings')} onClick={onNav} />
</> </>
@@ -137,7 +139,7 @@ export function AppSidebar({ member, taskBadge = 0, commsBadge = 0, paymentBadge
</div> </div>
<div className="flex-1 text-left min-w-0"> <div className="flex-1 text-left min-w-0">
<p className="text-[var(--sidebar-foreground)] text-xs font-medium truncate">{member.display_name}</p> <p className="text-[var(--sidebar-foreground)] text-xs font-medium truncate">{member.display_name}</p>
<p className="text-[var(--sidebar-foreground)]/40 text-[10px] font-mono">{member.role} · {member.tier}</p> <p className="text-[var(--sidebar-foreground)]/40 text-[10px] font-mono">{roleName || member.role} · {member.tier}</p>
</div> </div>
<LogOut className="w-3.5 h-3.5 text-[var(--sidebar-foreground)]/30" /> <LogOut className="w-3.5 h-3.5 text-[var(--sidebar-foreground)]/30" />
</button> </button>
+21
View File
@@ -0,0 +1,21 @@
// The hackerspace.sh brand mark: a minimal terminal prompt glyph (a chevron
// and an underscore). Inherits the surrounding text color via currentColor,
// so it picks up the lime accent wherever it sits on the dark sidebar.
export function BrandMark({ className }: { className?: string }) {
return (
<svg
className={className}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2.5}
strokeLinecap="round"
strokeLinejoin="round"
role="img"
aria-label="hackerspace.sh"
>
<path d="M5 7l5 5-5 5" />
<path d="M13 17h6" />
</svg>
)
}
+36
View File
@@ -4,6 +4,42 @@ Append-only. Newest entries on top. Keep each entry to one screen.
--- ---
## 2026-05-15 (pass 13) — Customize hub, roles editor, logo revert
Branch: `main`.
### Goal
Three asks: (1) build the custom-roles editor (label rename/recolor + create/edit/delete custom roles) that pass 11 left as data-layer-only; (2) move all the per-space customization (Roles, Tiers, Areas, Invites, Onboarding) out of the overloaded Settings tab strip into a dedicated `/customize` hub with its own nav, leaving Settings for space identity / visibility / integrations / webhooks; (3) revert the brand mark from `AtlasLogo` (the globe) back to the original terminal `>_` glyph and give the favicon a matching terminal mark.
### Decisions
- IA: a single sidebar entry "Customize" (admin/board) -> `/customize` hub with a left section rail (Roles, Tiers, Areas, Invites, Onboarding). Keeps the sidebar lean (audit finding: 16+ items already) while giving customization a discoverable home distinct from operational Settings. Settings slimmed to Space, Visibility, Integrations, Webhooks.
- Logo: restore `IcoTerminal` for nav/footer/onboarding header; replace `public/logo.svg` with a terminal `>_` glyph for the favicon.
### What shipped
- **Brand mark reverted.** New `components/brand-mark.tsx` (a terminal `>_` glyph, currentColor). Swapped into the landing nav + footer and the onboarding header. `public/logo.svg` rewritten as the matching lime `>_` favicon. The dead local `IcoTerminal` in the landing page was removed. `AtlasLogo` stays only on the `(resources)` page (it is that project's own art).
- **`/customize` hub** (`app/(app)/customize/`): server `page.tsx` gates admin/board and fetches everything; thin `customize-client.tsx` shell with a left section rail; one file per panel under `panels/` (`roles-panel`, `tiers-panel`, `areas-panel`, `invites-panel`, `onboarding-panel`, plus `card.tsx` and `types.ts`). Smart separation: the shell is ~75 lines, each panel self-contained.
- **Roles editor (new).** RolesPanel renames/recolors the five built-in roles via `upsertRoleLabel`, and full CRUD on custom roles. The pass-11 actions were write-only; this also adds the read path: `lib/role-labels.ts` (`getRoleLabelMap`, `roleDisplayName`, defaults) is now consumed in `(app)/layout.tsx` so the sidebar user card shows the renamed role.
- **Settings slimmed.** Removed the Roles/Tiers/Invites/Onboarding tabs and the Areas block from `settings-client.tsx` (down ~700 lines) and the matching fetches from `settings/page.tsx`. Settings now owns only Space, Integrations, Webhooks. Dead props/state/types removed.
- **Sidebar.** Added a "Customize" admin/board NavLink (`SlidersHorizontal`) above Settings.
- **Invite share links.** `InvitesPanel` has Copy code and Copy link; the link is `/signup?invite=CODE`. `app/signup/page.tsx` reads `?invite=` on mount, prefills the code, and preselects join mode.
### Deferred (tracked)
- `types/database.ts` is out of sync (missing space_tiers/space_invites/space_onboarding_steps/space_role_labels/space_custom_roles/space_member_custom_roles/forum_threads/comments and the two onboarding columns on space_members). Queries use loose casts so the build is green; this is type-hygiene debt, not a runtime bug.
- Renamed-role display only reaches the sidebar so far. Members table/edit-select and badges still show the raw enum. The helper exists; wiring the remaining surfaces is a small follow-up.
- `settings-client.tsx` is still ~700 lines (space form + visibility + integrations + webhooks + integration modal). Worth splitting next, same pattern as the customize panels.
- Custom-role assignment to members has actions (`assignCustomRole`/`unassignCustomRole`) but no UI yet.
### Verification
- `pnpm test` 266/266. `pnpm build` green; `/customize`, `/onboarding`, slimmed `/settings` all in the route table.
- Migration: none this pass (UI/IA only; pass-11/12 migrations already in prod).
---
## 2026-05-15 (pass 12) — Configurable member onboarding + UX research ## 2026-05-15 (pass 12) — Configurable member onboarding + UX research
Branch: `main`. Branch: `main`.
+54
View File
@@ -0,0 +1,54 @@
import type { SupabaseClient } from '@supabase/supabase-js'
// The five built-in roles. The member_role enum still drives all RLS; these
// labels are presentation only. A space can override the display name and
// color of any built-in role via space_role_labels.
export const BUILTIN_ROLES = ['admin', 'board', 'treasurer', 'member', 'associate'] as const
export type BuiltinRole = (typeof BUILTIN_ROLES)[number]
export const DEFAULT_ROLE_LABELS: Record<BuiltinRole, { name: string; color: string }> = {
admin: { name: 'Admin', color: '#d4ff00' },
board: { name: 'Board', color: '#7dd3fc' },
treasurer: { name: 'Treasurer', color: '#86efac' },
member: { name: 'Member', color: '#e5e7eb' },
associate: { name: 'Associate', color: '#cbd5e1' },
}
export interface RoleLabel {
role: string
name: string
description: string | null
color: string
}
// Resolves the effective label set for a space: defaults merged with any
// space_role_labels overrides. Safe to call from server components.
export async function getRoleLabelMap(
supabase: SupabaseClient,
spaceId: string,
): Promise<Record<string, RoleLabel>> {
const map: Record<string, RoleLabel> = {}
for (const r of BUILTIN_ROLES) {
map[r] = { role: r, name: DEFAULT_ROLE_LABELS[r].name, description: null, color: DEFAULT_ROLE_LABELS[r].color }
}
const { data } = await supabase
.from('space_role_labels')
.select('role, display_name, description, color')
.eq('space_id', spaceId)
for (const row of data ?? []) {
const base = map[row.role] ?? { role: row.role, name: row.role, description: null, color: '#e5e7eb' }
map[row.role] = {
role: row.role,
name: row.display_name?.trim() || base.name,
description: row.description ?? null,
color: row.color?.trim() || base.color,
}
}
return map
}
export function roleDisplayName(map: Record<string, RoleLabel> | null | undefined, role: string): string {
if (map && map[role]) return map[role].name
const d = DEFAULT_ROLE_LABELS[role as BuiltinRole]
return d ? d.name : role
}
+3 -26
View File
@@ -1,27 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="60 -5 280 350" role="img" aria-label="hackerspace.sh logo"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#d4ff00" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="hackerspace.sh">
<circle cx="200" cy="185" r="115" stroke="currentColor" fill="none" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/> <path d="M5 7l5 5-5 5"/>
<ellipse cx="200" cy="185" rx="45" ry="115" stroke="currentColor" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/> <path d="M13 17h6"/>
<ellipse cx="200" cy="185" rx="85" ry="115" stroke="currentColor" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="85" y1="185" x2="315" y2="185" stroke="currentColor" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
<ellipse cx="200" cy="133" rx="100" ry="28" stroke="currentColor" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
<ellipse cx="200" cy="237" rx="100" ry="28" stroke="currentColor" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
<g fill="currentColor" stroke="none">
<circle cx="85" cy="185" r="9"/><circle cx="85" cy="185" r="3.5" fill="#0c0c0c"/>
<circle cx="115" cy="185" r="7"/><circle cx="115" cy="185" r="2.5" fill="#0c0c0c"/>
<circle cx="155" cy="185" r="7"/><circle cx="155" cy="185" r="2.5" fill="#0c0c0c"/>
<circle cx="245" cy="185" r="7"/><circle cx="245" cy="185" r="2.5" fill="#0c0c0c"/>
<circle cx="285" cy="185" r="7"/><circle cx="285" cy="185" r="2.5" fill="#0c0c0c"/>
<circle cx="315" cy="185" r="9"/><circle cx="315" cy="185" r="3.5" fill="#0c0c0c"/>
<circle cx="200" cy="70" r="8"/><circle cx="200" cy="70" r="3" fill="#0c0c0c"/>
<circle cx="200" cy="300" r="8"/><circle cx="200" cy="300" r="3" fill="#0c0c0c"/>
</g>
<g>
<circle cx="145" cy="160" r="11" fill="#d4ff00"/>
<circle cx="145" cy="160" r="4.5" fill="#0c0c0c"/>
<circle cx="145" cy="160" r="16" stroke="#d4ff00" fill="none" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<g>
<circle cx="260" cy="205" r="10" fill="#d4ff00"/>
<circle cx="260" cy="205" r="4" fill="#0c0c0c"/>
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 252 B