Files
TaxHacker_s23/components/sidebar/sidebar.tsx
Vasily Zubarev 0b98a2c307 (squash) init
feat: filters, settings, backups

fix: ts compile errors

feat: new dashboard, webp previews and settings

feat: use webp for pdfs

feat: use webp

fix: analyze resets old data

fix: switch to corsproxy

fix: switch to free cors

fix: max upload limit

fix: currency conversion

feat: transaction export

fix: currency conversion

feat: refactor settings actions

feat: new loader

feat: README + LICENSE

doc: update readme

doc: update readme

doc: update readme

doc: update screenshots

ci: bump prisma
2025-03-16 21:29:20 +01:00

140 lines
4.8 KiB
TypeScript

"use client"
import { useNotification } from "@/app/context"
import { UploadButton } from "@/components/files/upload-button"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarGroup,
SidebarGroupContent,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
SidebarRail,
SidebarTrigger,
useSidebar,
} from "@/components/ui/sidebar"
import { ClockArrowUp, FileText, LayoutDashboard, Settings, Sparkles, Upload } from "lucide-react"
import Link from "next/link"
import { usePathname } from "next/navigation"
import { useEffect } from "react"
import { Blinker } from "./blinker"
import { SidebarMenuItemWithHighlight } from "./sidebar-item"
export function AppSidebar({
settings,
unsortedFilesCount,
}: {
settings: Record<string, string>
unsortedFilesCount: number
}) {
const { setOpenMobile } = useSidebar()
const pathname = usePathname()
const { notification } = useNotification()
// Hide sidebar on mobile when clicking an item
useEffect(() => {
setOpenMobile(false)
}, [pathname, setOpenMobile])
return (
<>
<Sidebar collapsible="icon">
<SidebarHeader>
<Link href="/" className="flex items-center gap-2 p-2">
<Avatar className="h-12 w-12 rounded-lg">
<AvatarImage src="/logo/256.png" />
<AvatarFallback className="rounded-lg">AI</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-left leading-tight">
<span className="truncate font-semibold">{settings.app_title}</span>
<span className="truncate text-xs">Beta</span>
</div>
<SidebarTrigger className="md:hidden" />
</Link>
</SidebarHeader>
<SidebarContent>
<SidebarGroup>
<UploadButton className="w-full mt-4 mb-2">
<Upload className="mr-2 h-4 w-4" />
<span>Upload</span>
</UploadButton>
</SidebarGroup>
<SidebarGroup>
<SidebarGroupContent>
<SidebarMenu>
<SidebarMenuItemWithHighlight href="/">
<SidebarMenuButton asChild>
<Link href="/">
<LayoutDashboard />
<span>Home</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItemWithHighlight>
<SidebarMenuItemWithHighlight href="/transactions">
<SidebarMenuButton asChild>
<Link href="/transactions">
<FileText />
<span>Transactions</span>
{notification && notification.code === "sidebar.transactions" && notification.message && (
<Blinker />
)}
<span></span>
</Link>
</SidebarMenuButton>
</SidebarMenuItemWithHighlight>
<SidebarMenuItemWithHighlight href="/unsorted">
<SidebarMenuButton asChild>
<Link href="/unsorted">
<ClockArrowUp />
<span>Unsorted</span>
{unsortedFilesCount > 0 && (
<span className="flex h-5 w-5 items-center justify-center rounded-full bg-primary text-xs font-medium text-primary-foreground">
{unsortedFilesCount}
</span>
)}
{notification && notification.code === "sidebar.unsorted" && notification.message && <Blinker />}
<span></span>
</Link>
</SidebarMenuButton>
</SidebarMenuItemWithHighlight>
<SidebarMenuItemWithHighlight href="/settings">
<SidebarMenuButton asChild>
<Link href="/settings">
<Settings />
<span>Settings</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItemWithHighlight>
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarContent>
<SidebarRail />
<SidebarFooter>
<SidebarGroup>
<SidebarGroupContent>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton asChild>
<Link href="https://vas3k.com/donate/" target="_blank">
<Sparkles />
Thank the author
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarFooter>
</Sidebar>
</>
)
}