'use client'; import { useQuery } from '@tanstack/react-query'; import Link from 'next/link'; import api from '@/lib/api'; import { useAuthStore } from '@/lib/store'; import type { Application } from '@/types'; const statusColors: Record = { running: 'bg-green-100 text-green-700', pending: 'bg-yellow-100 text-yellow-700', building: 'bg-blue-100 text-blue-700', deploying: 'bg-blue-100 text-blue-700', failed: 'bg-red-100 text-red-700', build_failed: 'bg-red-100 text-red-700', stopped: 'bg-gray-100 text-gray-700', }; export default function DashboardPage() { const user = useAuthStore((s) => s.user); const { data: apps = [], isLoading } = useQuery({ queryKey: ['applications'], queryFn: () => api.get('/applications').then((r) => r.data), }); const runningApps = apps.filter( (a) => a.deployments?.some((d) => d.status === 'running'), ); return (

Welcome back, {user?.firstName}! ๐Ÿ‘‹

Here's an overview of your applications.

{/* Stats */}

Total Apps

{apps.length}

Running

{runningApps.length}

Deployments (7d)

{apps.reduce((sum, a) => sum + (a.deployments?.length || 0), 0)}

{/* Recent Applications */}

Recent Applications

+ New Application
{isLoading ? (
Loading...
) : apps.length === 0 ? (

No applications yet

Deploy your first application to get started.

Deploy your first app
) : (
{apps.slice(0, 5).map((app) => { const latestDeploy = app.deployments?.[0]; const status = latestDeploy?.status || 'pending'; return (
{app.runtime === 'nodejs' ? '๐ŸŸฉ' : '๐ŸŸง'}

{app.name}

{app.runtime} ยท {app.replicas} replica{app.replicas > 1 ? 's' : ''} {app.databaseType !== 'none' && ` ยท ${app.databaseType}`}

{status} ); })}
)}
); }