auth: eliminar flash do login
- Simplifica AuthGuard para não redirecionar no cliente (gate feito no middleware) - Adiciona skeleton de carregamento no AppShell enquanto - Troca anchors por Next Link no sidebar para navegação client-side Sem mudanças de schema/DB; apenas UX e roteamento no cliente.
This commit is contained in:
parent
32488d48ca
commit
c88622d762
3 changed files with 61 additions and 43 deletions
|
|
@ -1,27 +1,59 @@
|
|||
"use client"
|
||||
|
||||
import { Suspense, type ReactNode } from "react"
|
||||
|
||||
|
||||
import { AppSidebar } from "@/components/app-sidebar"
|
||||
import { AuthGuard } from "@/components/auth/auth-guard"
|
||||
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"
|
||||
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import { useAuth } from "@/lib/auth-client"
|
||||
|
||||
interface AppShellProps {
|
||||
header: ReactNode
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export function AppShell({ header, children }: AppShellProps) {
|
||||
return (
|
||||
<SidebarProvider>
|
||||
<AppSidebar />
|
||||
<SidebarInset>
|
||||
export function AppShell({ header, children }: AppShellProps) {
|
||||
const { isLoading } = useAuth()
|
||||
return (
|
||||
<SidebarProvider>
|
||||
<AppSidebar />
|
||||
<SidebarInset>
|
||||
<Suspense fallback={null}>
|
||||
<AuthGuard />
|
||||
</Suspense>
|
||||
{header}
|
||||
<main className="flex flex-1 flex-col gap-8 bg-gradient-to-br from-background via-background to-primary/10 pb-12 pt-6">
|
||||
{children}
|
||||
</main>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
)
|
||||
}
|
||||
{isLoading ? (
|
||||
<div className="px-4 pt-4 lg:px-6">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<Skeleton className="h-7 w-48" />
|
||||
<div className="hidden items-center gap-2 sm:flex">
|
||||
<Skeleton className="h-9 w-28" />
|
||||
<Skeleton className="h-9 w-28" />
|
||||
</div>
|
||||
</div>
|
||||
<Skeleton className="mt-2 h-4 w-72" />
|
||||
</div>
|
||||
) : (
|
||||
header
|
||||
)}
|
||||
<main className="flex flex-1 flex-col gap-8 bg-gradient-to-br from-background via-background to-primary/10 pb-12 pt-6">
|
||||
{isLoading ? (
|
||||
<div className="space-y-6">
|
||||
<div className="px-4 lg:px-6">
|
||||
<div className="grid gap-6 lg:grid-cols-2">
|
||||
<Skeleton className="h-56 w-full rounded-xl" />
|
||||
<Skeleton className="h-56 w-full rounded-xl" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="px-4 lg:px-6">
|
||||
<Skeleton className="h-64 w-full rounded-xl" />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
children
|
||||
)}
|
||||
</main>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue