diff --git a/packages/frontend/src/Index.tsx b/packages/frontend/src/Index.tsx index db9a564..edf3284 100644 --- a/packages/frontend/src/Index.tsx +++ b/packages/frontend/src/Index.tsx @@ -3,11 +3,11 @@ import type { IssueResponse, OrganisationResponse, ProjectResponse, UserRecord } import { useEffect, useRef, useState } from "react"; import { Link } from "react-router-dom"; import { CreateIssue } from "@/components/create-issue"; -import { CreateOrganisation } from "@/components/create-organisation"; import { CreateProject } from "@/components/create-project"; import { IssueDetailPane } from "@/components/issue-detail-pane"; import { IssuesTable } from "@/components/issues-table"; import LogOutButton from "@/components/log-out-button"; +import { OrganisationSelect } from "@/components/organisation-select"; import SmallUserDisplay from "@/components/small-user-display"; import { DropdownMenu, @@ -36,7 +36,6 @@ function Index() { const organisationsRef = useRef(false); const [organisations, setOrganisations] = useState([]); - const [organisationSelectOpen, setOrganisationSelectOpen] = useState(false); const [selectedOrganisation, setSelectedOrganisation] = useState(null); const [projects, setProjects] = useState([]); @@ -161,59 +160,14 @@ function Index() {
{/* organisation selection */} - + /> {/* project selection - only shown when organisation is selected */} {selectedOrganisation && ( diff --git a/packages/frontend/src/components/organisation-select.tsx b/packages/frontend/src/components/organisation-select.tsx new file mode 100644 index 0000000..230a9bc --- /dev/null +++ b/packages/frontend/src/components/organisation-select.tsx @@ -0,0 +1,74 @@ +import type { OrganisationResponse } from "@issue/shared"; +import { useState } from "react"; +import { CreateOrganisation } from "@/components/create-organisation"; +import { Button } from "@/components/ui/button"; +import { + Select, + SelectContent, + SelectItem, + SelectSeparator, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; + +export function OrganisationSelect({ + organisations, + selectedOrganisation, + onSelectedOrganisationChange, + onCreateOrganisation, + placeholder = "Select Organisation", +}: { + organisations: OrganisationResponse[]; + selectedOrganisation: OrganisationResponse | null; + onSelectedOrganisationChange: (organisation: OrganisationResponse | null) => void; + onCreateOrganisation?: (organisationId: number) => void | Promise; + placeholder?: string; +}) { + const [open, setOpen] = useState(false); + + return ( + + ); +}