diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 1430e59..1a8344c 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -2,6 +2,8 @@ import { setRequestLocale } from 'next-intl/server'; import { hasLocale } from 'next-intl'; import { notFound } from 'next/navigation'; import { routing } from '@/i18n/routing'; +import { AppShell } from '@/components/core/AppShell'; +import { AppNav } from '@/components/core/AppNav'; export function generateStaticParams() { return routing.locales.map((locale) => ({ locale })); @@ -22,5 +24,10 @@ export default async function LocaleLayout({ setRequestLocale(locale); - return <>{children}; + return ( + + +
{children}
+
+ ); } diff --git a/src/components/core/AuthNavActions.tsx b/src/components/core/AuthNavActions.tsx new file mode 100644 index 0000000..7d04efe --- /dev/null +++ b/src/components/core/AuthNavActions.tsx @@ -0,0 +1,70 @@ +"use client"; + +import Link from "next/link"; +import { useTranslations } from "next-intl"; +import { routes } from "@/lib/routes"; +import { authClient } from "@/lib/auth-client"; +import { Button } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +interface AuthNavActionsProps { + className?: string; +} + +export function AuthNavActions({ className }: AuthNavActionsProps) { + const t = useTranslations("Navigation"); + const { data: session, isPending } = authClient.useSession(); + + if (isPending) { + return ( +
+
+
+ ); + } + + const isAuthenticated = !!session?.user; + + const handleSignOut = async () => { + await authClient.signOut({ + fetchOptions: { + onSuccess: () => { + window.location.href = routes.public.home; + }, + }, + }); + }; + + return ( +
+ {isAuthenticated ? ( + <> +
+ + +
+ + + ) : ( +
+ + +
+ )} +
+ ); +}