mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
feat: guest auth (#141)
* feat: Start using guest auth * feat: Implement more functionality to work as guest * chore: update package and tweak public route * chore: update root package json * chore: update web package json --------- Co-authored-by: Aslam H <iupin5212@gmail.com>
This commit is contained in:
@@ -1,32 +1,30 @@
|
||||
import { SignedInClient } from "@/components/custom/clerk/signed-in-client"
|
||||
"use client"
|
||||
|
||||
import { Sidebar } from "@/components/custom/sidebar/sidebar"
|
||||
import { JazzClerkAuth, JazzProvider } from "@/lib/providers/jazz-provider"
|
||||
import { currentUser } from "@clerk/nextjs/server"
|
||||
import { CommandPalette } from "@/components/custom/command-palette/command-palette"
|
||||
import { useAccountOrGuest } from "@/lib/providers/jazz-provider"
|
||||
import { usePathname } from "next/navigation"
|
||||
import PublicHomeRoute from "@/components/routes/public/PublicHomeRoute"
|
||||
|
||||
export default async function PageLayout({ children }: { children: React.ReactNode }) {
|
||||
const user = await currentUser()
|
||||
export default function PageLayout({ children }: { children: React.ReactNode }) {
|
||||
const { me } = useAccountOrGuest()
|
||||
const pathname = usePathname()
|
||||
|
||||
if (!user) {
|
||||
return children
|
||||
if (me._type === "Anonymous" && pathname === "/") {
|
||||
return <PublicHomeRoute />
|
||||
}
|
||||
|
||||
return (
|
||||
<JazzClerkAuth>
|
||||
<SignedInClient>
|
||||
<JazzProvider>
|
||||
<div className="flex h-full min-h-full w-full flex-row items-stretch overflow-hidden">
|
||||
<Sidebar />
|
||||
<CommandPalette />
|
||||
<div className="flex h-full min-h-full w-full flex-row items-stretch overflow-hidden">
|
||||
<Sidebar />
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<main className="relative flex flex-auto flex-col place-items-stretch overflow-auto lg:my-2 lg:mr-2 lg:rounded-md lg:border">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</JazzProvider>
|
||||
</SignedInClient>
|
||||
</JazzClerkAuth>
|
||||
{me._type !== "Anonymous" && <CommandPalette />}
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<main className="relative flex flex-auto flex-col place-items-stretch overflow-auto lg:my-2 lg:mr-2 lg:rounded-md lg:border">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Toaster } from "@/components/ui/sonner"
|
||||
import { ConfirmProvider } from "@/lib/providers/confirm-provider"
|
||||
import { DeepLinkProvider } from "@/lib/providers/deep-link-provider"
|
||||
import { GeistMono, GeistSans } from "./fonts"
|
||||
import { JazzAndAuth } from "@/lib/providers/jazz-provider"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Learn Anything",
|
||||
@@ -27,7 +28,7 @@ export default function RootLayout({
|
||||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
||||
<JotaiProvider>
|
||||
<ConfirmProvider>
|
||||
{children}
|
||||
<JazzAndAuth>{children}</JazzAndAuth>
|
||||
<Toaster expand={false} />
|
||||
</ConfirmProvider>
|
||||
</JotaiProvider>
|
||||
|
||||
Reference in New Issue
Block a user