import Icon from "@mdi/react"; import { ChevronsUpDown } from "lucide-react"; import { useState } from "react"; import { Button } from "~/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "~/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger } from "~/components/ui/popover"; import { useCollection, useCollections } from "~/hooks/use-metadata"; import { colors } from "~/lib/color"; import { icons } from "~/lib/icon"; import { type CollectionId } from "~/lib/metadata"; import { cn } from "~/lib/utils"; type CollectionPickerProps = { onChange?: (collectionId?: CollectionId) => void; className?: string; } export function CollectionPicker(props: CollectionPickerProps) { const [open, setOpen] = useState(false); const [value, setValue] = useState(); const collections = useCollections(); return ( No collection found. { setValue(undefined); setOpen(false); props.onChange && props.onChange(undefined); }} > {collections.map((collection) => ( { setValue(collection.get("id")); setOpen(false); props.onChange && props.onChange(collection.get("id")); }} > ))} ); } function Entry(props: { collectionId?: CollectionId }) { const collection = useCollection(props.collectionId) return (
{collection?.get("icon") && }
{collection?.get("name") ?? "None"}
); }