Added /users/me route, and handling auth in frontend

This commit is contained in:
cdricms
2025-01-17 15:37:01 +01:00
parent 5405cc50d9
commit eb9883a1c3
20 changed files with 453 additions and 68 deletions

View File

@@ -10,6 +10,7 @@ import {
GalleryVerticalEnd,
Settings2,
Calendar,
Loader2,
} from "lucide-react";
import { NavMain } from "@/components/nav-main";
@@ -23,6 +24,8 @@ import {
SidebarHeader,
SidebarRail,
} from "@/components/ui/sidebar";
import useMe from "@/hooks/use-me";
import { useEffect } from "react";
// This is sample data.
const data = {
@@ -93,6 +96,8 @@ const data = {
};
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
const { user, isLoading, success, error } = useMe();
return (
<Sidebar collapsible="icon" {...props}>
<SidebarHeader>
@@ -102,7 +107,11 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
<NavMain items={data.navMain} />
</SidebarContent>
<SidebarFooter>
<NavUser user={data.user} />
{isLoading ? (
<Loader2 className="flex w-full min-w-0 flex-col gap-1 justify-center animate-spin" />
) : (
<NavUser user={user!} />
)}
</SidebarFooter>
<SidebarRail />
</Sidebar>