fix: bugs fixed

This commit is contained in:
Aaryan Khandelwal 2022-12-19 20:30:09 +05:30
parent c4079c4e0c
commit a2db04f9ff
35 changed files with 719 additions and 569 deletions

View file

@ -93,6 +93,7 @@ const IssueDetailSidebar: React.FC<Props> = ({
console.log(res);
reset(defaultValues);
issueLabelMutate((prevData) => [...(prevData ?? []), res], false);
submitChanges({ labels_list: [res.id] });
});
};
@ -103,7 +104,7 @@ const IssueDetailSidebar: React.FC<Props> = ({
});
};
console.log(issueDetail);
console.log(issueDetail?.labels, issueDetail?.labels_list);
return (
<>
@ -248,25 +249,32 @@ const IssueDetailSidebar: React.FC<Props> = ({
</div>
<div className="basis-1/2">
<div className="flex gap-1 flex-wrap">
{issueDetail?.label_details.map((label) => (
<span
key={label.id}
className="group flex items-center gap-1 border rounded-2xl text-xs px-1 py-0.5 hover:bg-red-50 hover:border-red-500 cursor-pointer"
onClick={() => {
const updatedLabels = issueDetail?.labels.filter((l) => l !== label.id);
submitChanges({
labels_list: updatedLabels,
});
}}
>
{issueDetail?.labels.map((label) => {
const singleLabel = issueLabels?.find((l) => l.id === label);
if (!singleLabel) return null;
return (
<span
className="h-2 w-2 rounded-full flex-shrink-0"
style={{ backgroundColor: label.colour ?? "green" }}
></span>
{label.name}
<XMarkIcon className="h-2 w-2 group-hover:text-red-500" />
</span>
))}
key={singleLabel.id}
className="group flex items-center gap-1 border rounded-2xl text-xs px-1 py-0.5 hover:bg-red-50 hover:border-red-500 cursor-pointer"
onClick={() => {
const updatedLabels = issueDetail?.labels.filter((l) => l !== label);
// submitChanges({
// labels_list: updatedLabels,
// });
console.log(updatedLabels);
}}
>
<span
className="h-2 w-2 rounded-full flex-shrink-0"
style={{ backgroundColor: singleLabel.colour ?? "green" }}
></span>
{singleLabel.name}
<XMarkIcon className="h-2 w-2 group-hover:text-red-500" />
</span>
);
})}
<Controller
control={control}
name="labels_list"
@ -274,9 +282,9 @@ const IssueDetailSidebar: React.FC<Props> = ({
<Listbox
as="div"
value={value}
multiple
onChange={(val: any) => submitChanges({ labels_list: val })}
className="flex-shrink-0"
multiple
>
{({ open }) => (
<>

View file

@ -58,7 +58,7 @@ const SelectAssignee: React.FC<Props> = ({ control, submitChanges }) => {
>
{({ open }) => (
<div className="relative">
<Listbox.Button className="w-full flex justify-end items-center gap-1 text-xs cursor-pointer">
<Listbox.Button className="w-full flex items-center gap-1 text-xs cursor-pointer">
<span
className={classNames(
value ? "" : "text-gray-900",
@ -121,9 +121,12 @@ const SelectAssignee: React.FC<Props> = ({ control, submitChanges }) => {
<Transition
show={open}
as={React.Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Listbox.Options className="absolute z-10 right-0 mt-1 w-auto bg-white shadow-lg max-h-28 rounded-md py-1 text-xs ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none">
<div className="py-1">

View file

@ -1,16 +1,17 @@
// react
import React from "react";
// react-hook-form
import { Control, Controller } from "react-hook-form";
// hooks
import useUser from "lib/hooks/useUser";
// headless ui
import { Listbox, Transition } from "@headlessui/react";
// ui
import { Spinner, CustomSelect } from "ui";
// icons
import { ArrowPathIcon } from "@heroicons/react/24/outline";
// types
import { IIssue } from "types";
// common
import { classNames } from "constants/common";
import { Spinner } from "ui";
import React from "react";
import { ArrowPathIcon, ChevronDownIcon } from "@heroicons/react/24/outline";
import CustomSelect from "ui/custom-select";
type Props = {
control: Control<IIssue, any>;
@ -29,7 +30,7 @@ const SelectCycle: React.FC<Props> = ({ control, handleCycleChange }) => {
<div className="sm:basis-1/2">
<Controller
control={control}
name="cycle"
name="issue_cycle"
render={({ field: { value } }) => (
<>
<CustomSelect
@ -40,7 +41,7 @@ const SelectCycle: React.FC<Props> = ({ control, handleCycleChange }) => {
"hidden truncate sm:block text-left"
)}
>
{value ? cycles?.find((c) => c.id === value)?.name : "None"}
{value ? cycles?.find((c) => c.id === value.cycle_detail.id)?.name : "None"}
</span>
}
value={value}