diff --git a/web/components/issues/select/project.tsx b/web/components/issues/select/project.tsx index 3adeef258..e58257d8f 100644 --- a/web/components/issues/select/project.tsx +++ b/web/components/issues/select/project.tsx @@ -1,7 +1,11 @@ -// hooks -import useProjects from "hooks/use-projects"; +import { useRouter } from "next/router"; +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; // ui import { CustomSelect } from "components/ui"; +// helpers +import { renderEmoji } from "helpers/emoji.helper"; // icons import { Clipboard } from "lucide-react"; @@ -10,17 +14,39 @@ export interface IssueProjectSelectProps { onChange: (value: string) => void; } -export const IssueProjectSelect: React.FC = ({ value, onChange }) => { - const { projects } = useProjects(); +export const IssueProjectSelect: React.FC = observer((props) => { + const { value, onChange } = props; + + const router = useRouter(); + const { workspaceSlug } = router.query; + + const { project: projectStore } = useMobxStore(); + + const projects = workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : undefined; + + const selectedProject = projects?.find((i) => i.id === value); return ( - - {projects?.find((i) => i.id === value)?.identifier ?? "Project"} - + selectedProject ? ( +
+ + {selectedProject.emoji + ? renderEmoji(selectedProject.emoji) + : selectedProject.icon_prop + ? renderEmoji(selectedProject.icon_prop) + : null} + +
{selectedProject.identifier}
+
+ ) : ( + <> + +
Select Project
+ + ) } onChange={(val: string) => onChange(val)} noChevron @@ -29,7 +55,16 @@ export const IssueProjectSelect: React.FC = ({ value, o projects.length > 0 ? ( projects.map((project) => ( - <>{project.name} +
+ + {project.emoji + ? renderEmoji(project.emoji) + : project.icon_prop + ? renderEmoji(project.icon_prop) + : null} + + <>{project.name} +
)) ) : ( @@ -40,4 +75,4 @@ export const IssueProjectSelect: React.FC = ({ value, o )}
); -}; +});