import React, { useState } from "react"; // react-hook-form import { Controller, useForm } from "react-hook-form"; // react-color import { TwitterPicker } from "react-color"; // headless ui import { Popover, Transition } from "@headlessui/react"; // ui import { CustomMenu, Input, PrimaryButton, SecondaryButton } from "components/ui"; // icons import { PencilIcon, RectangleGroupIcon } from "@heroicons/react/24/outline"; // types import { IIssueLabels } from "types"; type Props = { label: IIssueLabels; issueLabels: IIssueLabels[]; editLabel: (label: IIssueLabels) => void; handleLabelDelete: (labelId: string) => void; }; const defaultValues: Partial = { name: "", color: "#ff0000", }; const SingleLabel: React.FC = ({ label, issueLabels, editLabel, handleLabelDelete }) => { const [newLabelForm, setNewLabelForm] = useState(false); const { register, formState: { errors, isSubmitting }, watch, control, } = useForm({ defaultValues }); const children = issueLabels?.filter((l) => l.parent === label.id); return ( <> {children && children.length === 0 ? (
{label.name}
{/* Convert to group */} editLabel(label)}>Edit handleLabelDelete(label.id)}> Delete
{({ open }) => ( <> {watch("color") && watch("color") !== "" && ( )} ( onChange(value.hex)} /> )} /> )}
setNewLabelForm(false)}>Cancel {isSubmitting ? "Adding" : "Add"}
) : (

This is the label group title

This is the label title
)} ); }; export default SingleLabel;