import { useState } from 'react'; import { useCollection } from '@feltdb/core/react'; import { auditEvents, invitations, projects, teams } from '../feltdb'; import { useAuth } from '../context/AuthContext'; import { Projects } from './Projects'; import { Invitations } from './Invitations'; import { Activity } from './Activity'; import { Agents } from './Agents'; type View = 'overview' | 'projects' | 'invitations' | 'activity' | 'agents'; export function Dashboard() { const { user, organization, signOut } = useAuth(); const [view, setView] = useState('overview'); const projectState = useCollection(projects); const teamState = useCollection(teams); const invitationState = useCollection(invitations); const activityState = useCollection(auditEvents); const stats = [{ label: 'Projects', value: projectState.data.length }, { label: 'Teams', value: teamState.data.length }, { label: 'Invitations', value: invitationState.data.filter(item => item.status === 'pending').length }, { label: 'Activity', value: activityState.data.length }]; return
FeltDB
{user?.name}
{view === 'overview' && <>
{organization?.name}

Welcome, {user?.name.split(' ')[0]}.

State, workflows, and agents share one authorization boundary.

member · {organization?.id.slice(0, 12)}…
{stats.map(stat =>
{stat.label}{stat.value}
)}
Start here

One application, visible in Studio

}{view === 'projects' && }{view === 'invitations' && }{view === 'activity' && }{view === 'agents' && }
; }