"use client" import { useState, useEffect } from "react" import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Loader2 } from "lucide-react" import { useSession } from "next-auth/react" export const LinkedAccounts = () => { const [gitStatus, setGitStatus] = useState(false) const [isLoading, setIsLoading] = useState(false) const [isAdmin, setIsAdmin] = useState(false) const [error, setError] = useState(null) const [authStatus, setAuthStatus] = useState(false) const { data: session } = useSession() useEffect(() => { if (session?.user?.email) { setAuthStatus(true) } }, [session]) useEffect(() => { const fetchGitStatus = async () => { setIsLoading(true); try { const response = await fetch("/api/git/user") const data = await response.json() if (!response.ok) { if (data.error && !data.dismissErr) { throw new Error(data.error) } else if (response.status !== 404) { throw new Error(`HTTP error: ${response.status}`) } else { console.log(data.error) } } else { if (data.is_admin) { setIsAdmin(true) } if (!data.message) { setGitStatus(true) } } } catch (err: unknown) { if (err instanceof Error) { setError(err.message) } } finally { setIsLoading(false) } }; fetchGitStatus() }, []); return ( Linked Accounts LibreCloud-connected services you've linked to your account.
    {authStatus ? (
  • LibreCloud Auth
  • ) : (
  • LibreCloud Auth
  • )}
  • LibreCloud Mail
  • {isLoading ? ( ) : ( )} {isAdmin ? (
    LibreCloud Git Admin
    ) : ( LibreCloud Git )}
{error &&

{error}

}
) }