diff --git a/apps/app/components/issues/select/label.tsx b/apps/app/components/issues/select/label.tsx
index 2d4e5a179..f0a1d2d64 100644
--- a/apps/app/components/issues/select/label.tsx
+++ b/apps/app/components/issues/select/label.tsx
@@ -1,15 +1,13 @@
-import React, { useEffect, useState } from "react";
+import React, { useState } from "react";
import { useRouter } from "next/router";
import useSWR from "swr";
-// react-hook-form
-import { useForm } from "react-hook-form";
// headless ui
import { Combobox, Transition } from "@headlessui/react";
// icons
-import { RectangleGroupIcon, TagIcon } from "@heroicons/react/24/outline";
+import { PlusIcon, RectangleGroupIcon, TagIcon } from "@heroicons/react/24/outline";
// services
import issuesServices from "services/issues.service";
// types
@@ -18,55 +16,26 @@ import type { IIssueLabels } from "types";
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
type Props = {
+ setIsOpen: React.Dispatch
>;
value: string[];
onChange: (value: string[]) => void;
projectId: string;
};
-const defaultValues: Partial = {
- name: "",
-};
-
-export const IssueLabelSelect: React.FC = ({ value, onChange, projectId }) => {
+export const IssueLabelSelect: React.FC = ({ setIsOpen, value, onChange, projectId }) => {
// states
const [query, setQuery] = useState("");
const router = useRouter();
const { workspaceSlug } = router.query;
- const [isOpen, setIsOpen] = useState(false);
-
- const { data: issueLabels, mutate: issueLabelsMutate } = useSWR(
+ const { data: issueLabels } = useSWR(
projectId ? PROJECT_ISSUE_LABELS(projectId) : null,
workspaceSlug && projectId
? () => issuesServices.getIssueLabels(workspaceSlug as string, projectId)
: null
);
- const onSubmit = async (data: IIssueLabels) => {
- if (!projectId || !workspaceSlug || isSubmitting) return;
- await issuesServices
- .createIssueLabel(workspaceSlug as string, projectId as string, data)
- .then((response) => {
- issueLabelsMutate((prevData) => [...(prevData ?? []), response], false);
- setIsOpen(false);
- reset(defaultValues);
- })
- .catch((error) => {
- console.log(error);
- });
- };
-
- const {
- formState: { isSubmitting },
- setFocus,
- reset,
- } = useForm({ defaultValues });
-
- useEffect(() => {
- isOpen && setFocus("name");
- }, [isOpen, setFocus]);
-
const filteredOptions =
query === ""
? issueLabels
@@ -175,48 +144,14 @@ export const IssueLabelSelect: React.FC = ({ value, onChange, projectId }
) : (
Loading...
)}
- {/*
- {isOpen ? (
-
-
-
-
-
- ) : (
-
- )}
-
*/}
+
diff --git a/apps/app/components/labels/create-label-modal.tsx b/apps/app/components/labels/create-label-modal.tsx
new file mode 100644
index 000000000..89c286012
--- /dev/null
+++ b/apps/app/components/labels/create-label-modal.tsx
@@ -0,0 +1,189 @@
+import React, { useEffect } from "react";
+
+import { useRouter } from "next/router";
+
+import { mutate } from "swr";
+
+// react-hook-form
+import { Controller, useForm } from "react-hook-form";
+// react-color
+import { TwitterPicker } from "react-color";
+// headless ui
+import { Dialog, Popover, Transition } from "@headlessui/react";
+// services
+import issuesService from "services/issues.service";
+// ui
+import { Button, Input } from "components/ui";
+// icons
+import { ChevronDownIcon } from "@heroicons/react/24/outline";
+// types
+import type { IIssueLabels, IState } from "types";
+// constants
+import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
+
+// types
+type Props = {
+ isOpen: boolean;
+ projectId: string;
+ handleClose: () => void;
+};
+
+const defaultValues: Partial