mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
(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
This commit is contained in:
8
components/sidebar/blinker.tsx
Normal file
8
components/sidebar/blinker.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export function Blinker() {
|
||||
return (
|
||||
<span className="relative flex size-3">
|
||||
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-sky-400 opacity-75"></span>
|
||||
<span className="relative inline-flex size-3 rounded-full bg-sky-500"></span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
33
components/sidebar/mobile-menu.tsx
Normal file
33
components/sidebar/mobile-menu.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
"use client"
|
||||
|
||||
import Link from "next/link"
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"
|
||||
import { useSidebar } from "../ui/sidebar"
|
||||
|
||||
export default function MobileMenu({
|
||||
settings,
|
||||
unsortedFilesCount,
|
||||
}: {
|
||||
settings: Record<string, string>
|
||||
unsortedFilesCount: number
|
||||
}) {
|
||||
const { toggleSidebar } = useSidebar()
|
||||
|
||||
return (
|
||||
<menu className="flex flex-row gap-2 p-2 items-center justify-between fixed top-0 left-0 w-full z-50 border-b-2 border-solid bg-background md:hidden">
|
||||
<Avatar className="h-10 w-10 rounded-lg cursor-pointer" onClick={toggleSidebar}>
|
||||
<AvatarImage src="/logo/256.png" />
|
||||
<AvatarFallback className="rounded-lg">AI</AvatarFallback>
|
||||
</Avatar>
|
||||
<Link href="/" className="text-lg font-bold">
|
||||
{settings.app_title}
|
||||
</Link>
|
||||
<Link
|
||||
href="/unsorted"
|
||||
className="flex h-6 w-6 items-center justify-center rounded-full bg-primary text-sm font-medium text-primary-foreground"
|
||||
>
|
||||
{unsortedFilesCount}
|
||||
</Link>
|
||||
</menu>
|
||||
)
|
||||
}
|
||||
32
components/sidebar/sidebar-item.tsx
Normal file
32
components/sidebar/sidebar-item.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
"use client"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { ComponentProps } from "react"
|
||||
import { SidebarMenuItem } from "../ui/sidebar"
|
||||
|
||||
export function SidebarMenuItemWithHighlight({
|
||||
href,
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: { href: string } & ComponentProps<typeof SidebarMenuItem>) {
|
||||
const pathname = usePathname()
|
||||
let isActive = false
|
||||
if (href === "/") {
|
||||
isActive = pathname === href
|
||||
} else {
|
||||
isActive = pathname.startsWith(href)
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarMenuItem
|
||||
className={cn(isActive && "bg-sidebar-accent font-medium text-sidebar-accent-foreground", className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</SidebarMenuItem>
|
||||
)
|
||||
}
|
||||
|
||||
// bg-primary text-primary-foreground
|
||||
139
components/sidebar/sidebar.tsx
Normal file
139
components/sidebar/sidebar.tsx
Normal file
@@ -0,0 +1,139 @@
|
||||
"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>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user