From d203ad340082c5d246e5395afb0fd111bf3e6ca7 Mon Sep 17 00:00:00 2001 From: Juan Di Toro Date: Sat, 9 Dec 2023 16:22:22 +0100 Subject: [PATCH] feat: connect the combobox to the api (sortof) --- src/components/SitesCombobox.tsx | 35 +++++--------------------------- src/types.d.ts | 17 ++++++++++------ src/utils.ts | 27 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/components/SitesCombobox.tsx b/src/components/SitesCombobox.tsx index dcafe09..e17eeef 100644 --- a/src/components/SitesCombobox.tsx +++ b/src/components/SitesCombobox.tsx @@ -17,38 +17,13 @@ import { PopoverTrigger } from "@/components/ui/popover" import { ChevronDownIcon } from "@heroicons/react/24/solid" - -type Status = { - value: string - label: string -} - -const statuses: Status[] = [ - { - value: "backlog", - label: "Backlog" - }, - { - value: "todo", - label: "Todo" - }, - { - value: "in progress", - label: "In Progress" - }, - { - value: "done", - label: "Done" - }, - { - value: "canceled", - label: "Canceled" - } -] +import useSWR from "swr" +import { getAvailableSites } from "@/utils" export function SitesCombobox() { + const {data: statuses} = useSWR('/api/statuses', getAvailableSites) const [open, setOpen] = React.useState(false) - const [selectedStatus, setSelectedStatus] = React.useState( + const [selectedStatus, setSelectedStatus] = React.useState( null ) @@ -67,7 +42,7 @@ export function SitesCombobox() { No results found. - {statuses.map((status) => ( + {statuses?.map((status) => (