From c75ca8203f8d3378db7e1781fa2f5afa49f8fe9e Mon Sep 17 00:00:00 2001 From: Saheb Giri <47132373+iamsahebgiri@users.noreply.github.com> Date: Thu, 30 Mar 2023 01:08:14 +0530 Subject: [PATCH] feat: add label to create view modal (#591) --- apps/app/components/views/form.tsx | 47 ++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/apps/app/components/views/form.tsx b/apps/app/components/views/form.tsx index cafb7b85b..24764d33e 100644 --- a/apps/app/components/views/form.tsx +++ b/apps/app/components/views/form.tsx @@ -10,12 +10,13 @@ import { Avatar, Input, PrimaryButton, SecondaryButton, TextArea } from "compone // types import { IView } from "types"; // constant -import { PROJECT_MEMBERS, STATE_LIST } from "constants/fetch-keys"; +import { PROJECT_ISSUE_LABELS, PROJECT_MEMBERS, STATE_LIST } from "constants/fetch-keys"; // helpers import { getStatesList } from "helpers/state.helper"; // services import stateService from "services/state.service"; import projectService from "services/project.service"; +import issuesService from "services/issues.service"; // components import { SelectFilters } from "components/views"; // icons @@ -61,6 +62,13 @@ export const ViewForm: React.FC = ({ : null ); + const { data: issueLabels } = useSWR( + projectId ? PROJECT_ISSUE_LABELS(projectId.toString()) : null, + workspaceSlug && projectId + ? () => issuesService.getIssueLabels(workspaceSlug as string, projectId.toString()) + : null + ); + const { register, formState: { errors, isSubmitting }, @@ -153,7 +161,7 @@ export const ViewForm: React.FC = ({ />
-
+
{Object.keys(filters ?? {}).map((key) => { const queryKey = key as keyof typeof filters; if (queryKey === "state") @@ -163,7 +171,10 @@ export const ViewForm: React.FC = ({ const state = statesList.find((state) => state.id === stateID); if (!state) return null; return ( -
+
{getStateGroupIcon(state?.group, "16", "16", state?.color)} {state?.name}
@@ -175,7 +186,10 @@ export const ViewForm: React.FC = ({ return (
{filters.priority?.map((priority) => ( -
+
{getPriorityIcon(priority)} {priority}
@@ -190,7 +204,10 @@ export const ViewForm: React.FC = ({ if (!member) return null; return ( -
+
{member.member.first_name && member.member.first_name !== "" ? member.member.first_name @@ -200,6 +217,26 @@ export const ViewForm: React.FC = ({ })}
); + else if (queryKey === "labels") + return ( +
+
+ {filters.labels?.map((labelId: string) => { + const label = issueLabels?.find((l) => l.id === labelId); + if (!label) return null; + return ( +
+
+ {label.name} +
+ ); + })} +
+
+ ); })}