import { mdiAccountGroup, mdiArrowRight, mdiCheckCircleOutline, mdiClockOutline, mdiFileDocumentEditOutline, mdiMicrophoneOutline, mdiViewDashboardOutline, } from '@mdi/js'; import axios from 'axios'; import Head from 'next/head'; import Link from 'next/link'; import { useRouter } from 'next/router'; import React from 'react'; import type { ReactElement } from 'react'; import BaseIcon from '../components/BaseIcon'; import SectionMain from '../components/SectionMain'; import { getPageTitle } from '../config'; import LayoutAuthenticated from '../layouts/Authenticated'; type Client = { id: string; name: string; company?: string; role_title?: string; next_session_at?: string; package?: { title?: string; }; }; type Session = { id: string; title?: string; ai_summary?: string; session_at?: string; client?: Client; }; type PrepBrief = { id: string; next_session_at?: string; previous_summary?: string; open_commitments?: string; suggested_questions?: string; sensitive_topics?: string; client_reflection?: string; client?: Client; }; type Summary = { counts: { clients: number; sessions: number; actionItems: number; resources: number; prepBriefs: number; }; activeClients: Client[]; nextSessions: Session[]; upcomingPrepBriefs: PrepBrief[]; }; const emptySummary: Summary = { counts: { clients: 0, sessions: 0, actionItems: 0, resources: 0, prepBriefs: 0, }, activeClients: [], nextSessions: [], upcomingPrepBriefs: [], }; function ShellCard({ children, className = '', }: { children: React.ReactNode; className?: string; }) { return (
{children}
); } const Dashboard = () => { const router = useRouter(); const [summary, setSummary] = React.useState(emptySummary); const [loading, setLoading] = React.useState(true); React.useEffect(() => { async function loadSummary() { const token = localStorage.getItem('token'); if (!token) { setLoading(false); router.push('/login'); return; } try { const response = await axios.get('/coaching/summary'); setSummary(response.data); } catch (error) { if (axios.isAxiosError(error) && error.response?.status === 401) { localStorage.removeItem('token'); localStorage.removeItem('user'); router.push('/login'); return; } throw error; } finally { setLoading(false); } } loadSummary(); }, [router]); const nextPrepBrief = summary.upcomingPrepBriefs[0]; const stats = [ { href: '/clients', icon: mdiAccountGroup, label: 'Active clients', value: summary.counts.clients, }, { href: '/session-memory', icon: mdiFileDocumentEditOutline, label: 'Session memories', value: summary.counts.sessions, }, { href: '/clients', icon: mdiCheckCircleOutline, label: 'Open commitments', value: summary.counts.actionItems, }, { href: '/session-memory', icon: mdiClockOutline, label: 'Prep briefs', value: summary.counts.prepBriefs, }, ]; return ( <> {getPageTitle('Dashboard')}
Workspace overview

Manage upcoming sessions, client notes, commitments, and follow-up drafts.

Review scheduled sessions, open tasks, recent notes, and drafts that need approval.

Start client session Open client records

Next session prep

{nextPrepBrief ? (

{nextPrepBrief.client?.name || 'Client session'}

{nextPrepBrief.client?.role_title} ·{' '} {nextPrepBrief.client?.company}

{nextPrepBrief.suggested_questions || nextPrepBrief.previous_summary}

Open prep
) : (

{loading ? 'Loading your coaching workspace...' : 'No upcoming session memory yet.'}

)}
{stats.map((stat) => (

{stat.label}

{loading ? '...' : stat.value}

))}

Client records

Active clients

View all
{summary.activeClients.map((client) => (

{client.name}

{client.role_title} · {client.company}

{client.package?.title || 'Coaching'}
))}

Recent intelligence

Session memory

Open
{summary.nextSessions.map((session) => (

{session.title}

{session.client?.name}

{session.ai_summary}

))}

Next-session prep

Ready prep briefs

Open clients
{summary.upcomingPrepBriefs.map((brief) => (

{brief.client?.name}

{brief.client?.role_title} · {brief.client?.company}

Ready

{brief.client_reflection || brief.suggested_questions || brief.previous_summary}

))} {summary.upcomingPrepBriefs.length === 0 && (

{loading ? 'Loading prep briefs...' : 'No prep briefs ready yet.'}

)}
); }; Dashboard.getLayout = function getLayout(page: ReactElement) { return {page}; }; export default Dashboard;