import React, { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { api } from "../services/api"; import { StatusBadge } from "../components/StatusBadge"; import { motion } from "motion/react"; import { useAuth } from "../hooks/useAuth"; interface Preview { id: number; prNumber: number; prTitle: string; commitSha: string; status: string; instanceIp: string | null; port: number; createdAt: string; updatedAt: string; lastActivityAt: string; repoOwner: string; repoName: string; } export function Dashboard() { const [previews, setPreviews] = useState([]); const [loading, setLoading] = useState(true); const { user } = useAuth(); const load = async () => { const res = await api.previews.list(); if (res.ok) setPreviews(res.data || []); setLoading(false); }; useEffect(() => { load(); }, []); useEffect(() => { const t = setInterval(load, 10000); return () => clearInterval(t); }, []); if (!user?.setupComplete && !loading) { return (
⚙️

Setup Required

Configure your Gitea and AWS credentials to get started.

Go to Settings
); } return (

Previews

{loading ? (
{[...Array(3)].map((_, i) => (
))}
) : previews.length === 0 ? (
🔍

No previews yet

Enable a repo and open a pull request to create your first preview.

Configure repos →
) : (
{previews.map((p, i) => (

{p.repoOwner}/{p.repoName}

PR #{p.prNumber}: {p.prTitle}

Commit: {p.commitSha.slice(0, 8)}

{p.status === "RUNNING" && p.instanceIp && ( e.stopPropagation()} className="inline-flex items-center gap-1 text-xs text-green-600 dark:text-green-400 hover:underline" > 🟢 http://{p.instanceIp}:{p.port} )}

Updated {new Date(p.updatedAt).toLocaleString()}

))}
)}
); }