import * as React from "react"; import { ChevronRight, LoaderIcon } from "lucide-react"; import { SearchForm } from "@/components/search-form"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarRail, } from "@/components/ui/sidebar"; import { getAllDays, getAllLines } from "@/db"; import { auth, signIn, signOut } from "@/auth"; import { refetchAllData } from "@/app/actions"; export async function AppSidebar({ ...props }: React.ComponentProps) { const allLines = await getAllLines(); const allDays = await getAllDays(); const data = { navMain: [ { title: "Dny", items: allDays.map((day) => ({ title: new Date(day).toLocaleDateString("cs-CZ", { weekday: "long", day: "numeric", month: "numeric", }), url: `/date/${day}`, isActive: false, // You can set this based on your routing logic })), }, { title: "Linie", items: allLines.map((line) => ({ title: line.name, url: `/line/${line.id}`, isActive: false, // You can set this based on your routing logic })), }, ], }; const session = await auth(); console.log("Session:", session); const username = session?.user?.name; return ( Rozcestník Kam jít? Oblíbené {/* We create a collapsible SidebarGroup for each parent. */} {data.navMain.map((item) => ( {item.title}{" "} {item.items.map((item) => ( {item.title} ))} ))} Správa{username ? ` (${username}) ` : " "} {!username && (
{ "use server"; await signIn("github"); }} > Přihlásit se přes GitHub
)} {username && ( <>
{ "use server"; await signOut(); }} > Odhlásit se
Refetch all data
)}
); }