refactor: swf not needed for now
This commit is contained in:
parent
81412d8cc8
commit
e18c76ca8b
|
@ -1,39 +1,39 @@
|
||||||
"use client"
|
import * as React from "react";
|
||||||
|
|
||||||
import * as React from "react"
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button"
|
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandEmpty,
|
CommandEmpty,
|
||||||
CommandGroup,
|
CommandGroup,
|
||||||
CommandInput,
|
CommandInput,
|
||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList
|
CommandList,
|
||||||
} from "@/components/ui/command"
|
} from "@/components/ui/command";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger
|
PopoverTrigger,
|
||||||
} from "@/components/ui/popover"
|
} from "@/components/ui/popover";
|
||||||
import { ChevronDownIcon } from "@heroicons/react/24/solid"
|
import { ChevronDownIcon } from "@heroicons/react/24/solid";
|
||||||
import useSWR from "swr"
|
import useSWR from "swr";
|
||||||
import { getAvailableSites } from "@/utils"
|
import { getAvailableSites } from "@/utils";
|
||||||
|
|
||||||
export function SitesCombobox() {
|
export function SitesCombobox() {
|
||||||
const {data: statuses} = useSWR('/api/statuses', getAvailableSites)
|
const { statuses } = getAvailableSites();
|
||||||
const [open, setOpen] = React.useState(false)
|
const [open, setOpen] = React.useState(false);
|
||||||
const [selectedStatus, setSelectedStatus] = React.useState<SelectOptions | null>(
|
const [selectedStatus, setSelectedStatus] =
|
||||||
null
|
React.useState<SelectOptions | null>(null);
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex- items-center space-x-4">
|
<div className="flex flex- items-center space-x-4">
|
||||||
<Popover open={open} onOpenChange={setOpen}>
|
<Popover open={open} onOpenChange={setOpen}>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<Button variant={"ghost"} className="max-w-[120px] focus:ring-2 focus:ring-ring px-2 font-bold items-center w-full flex justify-between text-white text-xs uppercase">
|
<Button
|
||||||
{selectedStatus ? <>{selectedStatus.label}</> : <>All Sites</>}
|
variant={"ghost"}
|
||||||
<ChevronDownIcon className="ml-3 w-5 h-5"/>
|
className="max-w-[120px] focus:ring-2 focus:ring-ring px-2 font-bold items-center w-full flex justify-between text-white text-xs uppercase"
|
||||||
|
>
|
||||||
|
{selectedStatus ? <>{selectedStatus.label}</> : <>All Sites</>}
|
||||||
|
<ChevronDownIcon className="ml-3 w-5 h-5" />
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="p-0" side="right" align="start">
|
<PopoverContent className="p-0" side="right" align="start">
|
||||||
|
@ -51,8 +51,8 @@ export function SitesCombobox() {
|
||||||
setSelectedStatus(
|
setSelectedStatus(
|
||||||
statuses.find((priority) => priority.value === value) ||
|
statuses.find((priority) => priority.value === value) ||
|
||||||
null
|
null
|
||||||
)
|
);
|
||||||
setOpen(false)
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{status.label}
|
{status.label}
|
||||||
|
@ -64,5 +64,5 @@ export function SitesCombobox() {
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue