()
| 6 | import { Link } from "react-router-dom"; |
| 7 | |
| 8 | export const OrgSelector = () => { |
| 9 | const { organizations } = useOrganizations(); |
| 10 | const { organization: currentOrganization } = useCurrentOrganization(); |
| 11 | const { projects } = useGetProjects(); |
| 12 | const { project: currentProject } = useCurrentProject(); |
| 13 | |
| 14 | return ( |
| 15 | <div className="flex text-sm"> |
| 16 | <div className="flex min-w-[200px] flex-col gap-y-2 rounded-r-lg p-2"> |
| 17 | <p className="mt-2 px-2 text-muted-foreground">Organizations</p> |
| 18 | <ul className="flex h-full flex-col"> |
| 19 | {organizations && |
| 20 | currentOrganization && |
| 21 | organizations.map((org) => ( |
| 22 | <li> |
| 23 | <Link |
| 24 | to={`/orgs/${org.id}`} |
| 25 | className="flex cursor-pointer items-center gap-x-2 rounded-md p-2 transition-all hover:bg-muted" |
| 26 | > |
| 27 | <div className="flex-1">{org.name}</div> |
| 28 | {org.id === currentOrganization.id && ( |
| 29 | <CheckIcon className="h-4 w-4 opacity-50" /> |
| 30 | )} |
| 31 | </Link> |
| 32 | </li> |
| 33 | ))} |
| 34 | </ul> |
| 35 | </div> |
| 36 | <div className="0 flex min-w-[200px] flex-col gap-y-2 rounded-r-lg border-l border-border bg-muted/30 p-2"> |
| 37 | <p className="mt-2 px-2 text-gray-500">Projects</p> |
| 38 | <ul className="flex h-full flex-col"> |
| 39 | {projects && |
| 40 | projects.map((project) => ( |
| 41 | <li className=""> |
| 42 | <Link |
| 43 | className="flex cursor-pointer items-center gap-x-2 rounded-md p-2 transition-all hover:bg-muted" |
| 44 | to={`/projects/${project.id}`} |
| 45 | > |
| 46 | <div className="flex-1">{project.name}</div> |
| 47 | {project.id === currentProject?.id && ( |
| 48 | <CheckIcon className="h-4 w-4 opacity-50" /> |
| 49 | )} |
| 50 | </Link> |
| 51 | </li> |
| 52 | ))} |
| 53 | </ul> |
| 54 | </div> |
| 55 | </div> |
| 56 | ); |
| 57 | }; |
nothing calls this directly
no test coverage detected