import { Link } from "@remix-run/react" import { logout } from "~/lib/auth.client" import { APP_NAME } from "~/lib/env" import { useStore } from "~/lib/store" export function MainLayout({ isLoggedIn, children, }: { isLoggedIn: boolean children: React.ReactNode }) { const setLoginModalOpened = useStore((store) => store.setLoginModalOpened) const links: Array<{ text: string; href?: string; onClick?: () => void }> = isLoggedIn ? [ { text: "Dashboard", href: "/dashboard", }, { text: "Log out", onClick() { logout() }, }, ] : [ { text: "Log in", onClick() { setLoginModalOpened(true) }, }, ] return ( <>
{APP_NAME}
..is under early testing, don't use this app in production.
{links.map((link) => { if (link.href) { return ( {link.text} ) } return ( ) })}
{children} ) }