"use client" import Link from "next/link" import TunnlLogo from "./tunnl-logo" import UserMenu from "./user-menu" import { useEffect, useState } from "react" import { authClient } from "@/lib/auth-client"; import { redirect, RedirectType } from 'next/navigation' export default function SiteHeader() { type SessionData = Awaited>; const [logedin, setLogedin] = useState(null) useEffect(() => { const fetchData = async () => { try { const result = await authClient.getSession() if (result.data != null) { setLogedin(result.data.user); } } catch (error) { console.error('Error fetching data:', error); } }; fetchData(); }, []); const logout = async () => { await authClient.signOut({ fetchOptions: { onSuccess: () => { redirect('/login', RedirectType.replace) } } }) } return (
tunnl.live
{logedin ? ( ) : ( <> Sign In
Sign in to save configurations & view history
)}
) }