"use client" import { useState } from "react" import Link from "next/link" import { usePathname } from "next/navigation" import { SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, } from "@/components/ui/sidebar" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { useAlbums } from "@/hooks/use-albums" import { ImageIcon, PlusIcon } from "lucide-react" export function AlbumSidebar() { const pathname = usePathname() const { albums, createAlbum } = useAlbums() const [isCreating, setIsCreating] = useState(false) const [newTitle, setNewTitle] = useState("") const handleCreate = async () => { if (!newTitle.trim()) return await createAlbum(newTitle.trim()).catch(() => {}) setNewTitle("") setIsCreating(false) } return ( Albums {isCreating && (
setNewTitle(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") handleCreate() if (e.key === "Escape") setIsCreating(false) }} />
)} {albums.map((album) => ( {album.title} ))}
) }