plane/apps/app/components/issues/select/project.tsx
Aaryan Khandelwal 3c2f5d12ed
feat: themes (#902)
* chore: add next theme and initial setup

* chore: add dark mode colors to layouts

* chore: user general setting page theming

* chore: dashboard theming

* chore: project page theming

* chore: workspace setting page theming

* chore: my issue page theming

* chore: cmdk theming

* chore: change hardcode bg and text color to theme

* chore: change color name according to the design

* style: fix card in the dashboard

* style: fix merge conflict design issues

* style: add light high contrast and dark high contrast

* style: fix cmd k menu color and selection

* feat: change theme from cmdk menu

* chore: add multiple theme field to custom theme

* chore: removed custom theming

* fix: build error

---------

Co-authored-by: Saheb Giri <iamsahebgiri@gmail.com>
2023-04-20 13:41:24 +05:30

67 lines
1.8 KiB
TypeScript

import { useRouter } from "next/router";
import useSWR from "swr";
// ui
import { CustomSelect } from "components/ui";
// icons
import { ClipboardDocumentListIcon } from "@heroicons/react/24/outline";
// services
import projectService from "services/project.service";
// fetch-keys
import { PROJECTS_LIST } from "constants/fetch-keys";
export interface IssueProjectSelectProps {
value: string;
onChange: (value: string) => void;
setActiveProject: React.Dispatch<React.SetStateAction<string | null>>;
}
export const IssueProjectSelect: React.FC<IssueProjectSelectProps> = ({
value,
onChange,
setActiveProject,
}) => {
const router = useRouter();
const { workspaceSlug } = router.query;
// Fetching Projects List
const { data: projects } = useSWR(
workspaceSlug ? PROJECTS_LIST(workspaceSlug as string) : null,
() => (workspaceSlug ? projectService.getProjects(workspaceSlug as string) : null)
);
return (
<CustomSelect
value={value}
label={
<>
<ClipboardDocumentListIcon className="h-3 w-3" />
<span className="block truncate">
{projects?.find((i) => i.id === value)?.identifier ?? "Project"}
</span>
</>
}
onChange={(val: string) => {
onChange(val);
setActiveProject(val);
}}
noChevron
>
{projects ? (
projects.length > 0 ? (
projects.map((project) => (
<CustomSelect.Option key={project.id} value={project.id}>
<>{project.name}</>
</CustomSelect.Option>
))
) : (
<p className="text-gray-400">No projects found!</p>
)
) : (
<div className="px-2 text-sm text-brand-secondary">Loading...</div>
)}
</CustomSelect>
);
};