/classes/manage (guarded by classes.manage) lists classes with inline create/edit, archive/restore, delete (refused once sessions exist), an optional grants-certification picker and a generic payment link, plus per-class session scheduling with cancel/delete. Sidebar gets a "Manage classes" link in the Admin block. The member-facing catalog/signup is the next phase.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { requireClassesManagerPage } from '@/lib/classes-guard'
|
|
import { ClassesManageClient } from './classes-manage-client'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export default async function ClassesManagePage() {
|
|
const { supabase, member } = await requireClassesManagerPage()
|
|
|
|
const [{ data: classes }, { data: sessions }, { data: certs }] = await Promise.all([
|
|
supabase
|
|
.from('classes')
|
|
.select('id, title, description, payment_link, capacity, is_active, grants_certification_id, created_at, updated_at')
|
|
.eq('space_id', member.space_id)
|
|
.order('is_active', { ascending: false })
|
|
.order('title', { ascending: true }),
|
|
supabase
|
|
.from('class_sessions')
|
|
.select('id, class_id, starts_at, ends_at, location, capacity, status, notes')
|
|
.eq('space_id', member.space_id)
|
|
.order('starts_at', { ascending: true }),
|
|
supabase
|
|
.from('certifications')
|
|
.select('id, name, is_active')
|
|
.eq('space_id', member.space_id)
|
|
.eq('is_active', true)
|
|
.order('name', { ascending: true }),
|
|
])
|
|
|
|
return (
|
|
<ClassesManageClient
|
|
initialClasses={classes ?? []}
|
|
initialSessions={sessions ?? []}
|
|
certs={certs ?? []}
|
|
/>
|
|
)
|
|
}
|