import * as React 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 { ChevronDownIcon } from "@heroicons/react/24/solid"; import { SelectOptions, SiteList } from "@/types.js"; import slugify from "slugify"; import { useEffect } from "react"; export function SitesCombobox({ siteList, onSiteSelect, }: { siteList: SiteList; onSiteSelect: React.Dispatch>; }) { const sites = Object.entries(siteList).map((item) => { return { label: item[1].name, value: slugify(item[0]), }; }); const [open, setOpen] = React.useState(false); const [selectedSite, setSelectedSite] = React.useState( null ); useEffect(() => { onSiteSelect(selectedSite?.value as any); }, [selectedSite]); return (
No results found. {sites?.map((status) => ( { setSelectedSite( sites.find((site) => site.value === value) || null ); setOpen(false); }} > {status.label} ))}
); }