"use client"; import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import { useAuth } from "@/context/AuthContext"; import { Terminal } from "lucide-react"; export default function LogsPage() { const { user } = useAuth(); const router = useRouter(); const [applications, setApplications] = useState([]); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(""); useEffect(() => { fetchApplications(); }, []); async function fetchApplications() { setIsLoading(true); try { const response = await fetch( "http://localhost:8080/twirp/applications.ApplicationsService/ListApplications", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token: localStorage.getItem("token"), }), }, ); const data = await response.json(); if (data.applications) { setApplications(data.applications); } } catch (error) { console.error("Error fetching applications:", error); setError("Failed to load applications"); } finally { setIsLoading(false); } } const handleApplicationClick = (appId) => { router.push(`/dashboard/logs/${appId}`); }; return (
Loading applications...
No applications found.