Refactoring Phase 1 (#199)
* style: added cta at the bottom of sidebar, added missing icons as well, showing dynamic workspace member count on workspace dropdown * refractor: running parallel request, made create/edit label function to async function * fix: sidebar dropdown content going below kanban items outside click detection in need help dropdown * refractor: making parallel api calls fix: create state input comes at bottom, create state input gets on focus automatically, form is getting submitted on enter click * refactoring file structure and signin page * style: changed text and added spinner for signing in loading * refractor: removed unused type * fix: my issue cta in profile page sending to 404 page * fix: added new s3 bucket url in next.config.js file increased image modal height * packaging UI components * eslint config * eslint fixes * refactoring changes * build fixes * minor fixes * adding todo comments for reference * refactor: cleared unused imports and re ordered imports * refactor: removed unused imports * fix: added workspace argument to useissues hook * refactor: removed api-routes file, unnecessary constants * refactor: created helpers folder, removed unnecessary constants * refactor: new context for issue view * refactoring issues page * build fixes * refactoring * refactor: create issue modal * refactor: module ui * fix: sub-issues mutation * fix: create more option in create issue modal * description form debounce issue * refactor: global component for assignees list * fix: link module interface * fix: priority icons and sub-issues count added * fix: cycle mutation in issue details page * fix: remove issue from cycle mutation * fix: create issue modal in home page * fix: removed unnecessary props * fix: updated create issue form status * fix: settings auth breaking * refactor: issue details page Co-authored-by: Dakshesh Jain <dakshesh.jain14@gmail.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: venkatesh-soulpage <venkatesh.marreboyina@soulpageit.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia1001@gmail.com>
This commit is contained in:
parent
9134b0c543
commit
9075f9441c
322 changed files with 14149 additions and 21378 deletions
|
|
@ -4,21 +4,22 @@ import { useRouter } from "next/router";
|
|||
|
||||
import useSWR, { mutate } from "swr";
|
||||
|
||||
// headless ui
|
||||
import { Dialog, Transition } from "@headlessui/react";
|
||||
// services
|
||||
import stateServices from "lib/services/state.service";
|
||||
import issuesServices from "lib/services/issues.service";
|
||||
// fetch api
|
||||
import { STATE_LIST, PROJECT_ISSUES_LIST } from "constants/fetch-keys";
|
||||
// common
|
||||
import { groupBy } from "constants/common";
|
||||
// icons
|
||||
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
|
||||
// ui
|
||||
import { Button } from "ui";
|
||||
|
||||
// types
|
||||
import type { IState } from "types";
|
||||
// services
|
||||
import stateServices from "services/state.service";
|
||||
import issuesServices from "services/issues.service";
|
||||
// ui
|
||||
import { Button } from "components/ui";
|
||||
// helpers
|
||||
import { groupBy } from "helpers/array.helper";
|
||||
// fetch api
|
||||
import { STATE_LIST, PROJECT_ISSUES_LIST } from "constants/fetch-keys";
|
||||
|
||||
type Props = {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
import React, { useEffect } from "react";
|
||||
// swr
|
||||
|
||||
import { mutate } from "swr";
|
||||
// react hook form
|
||||
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
// react color
|
||||
|
||||
import { TwitterPicker } from "react-color";
|
||||
// headless
|
||||
|
||||
import { Popover, Transition } from "@headlessui/react";
|
||||
// constants
|
||||
import type { IState } from "types";
|
||||
import { GROUP_CHOICES } from "constants/";
|
||||
import { STATE_LIST } from "constants/fetch-keys";
|
||||
// services
|
||||
import stateService from "lib/services/state.service";
|
||||
import stateService from "services/state.service";
|
||||
// ui
|
||||
import { Button, Input, Select, Spinner } from "ui";
|
||||
import { Button, Input, Select } from "components/ui";
|
||||
// types
|
||||
import type { IState } from "types";
|
||||
|
||||
type Props = {
|
||||
workspaceSlug?: string;
|
||||
|
|
@ -52,6 +52,19 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
defaultValues,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data === null) return;
|
||||
reset(data);
|
||||
}, [data, reset]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!data)
|
||||
reset({
|
||||
...defaultValues,
|
||||
group: selectedGroup ?? "backlog",
|
||||
});
|
||||
}, [selectedGroup, data, reset]);
|
||||
|
||||
const handleClose = () => {
|
||||
onClose();
|
||||
reset({ name: "", color: "#000000", group: "backlog" });
|
||||
|
|
@ -66,7 +79,7 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
await stateService
|
||||
.createState(workspaceSlug, projectId, { ...payload })
|
||||
.then((res) => {
|
||||
mutate<IState[]>(STATE_LIST(projectId), (prevData) => [...(prevData ?? []), res], false);
|
||||
mutate<IState[]>(STATE_LIST(projectId), (prevData) => [...(prevData ?? []), res]);
|
||||
handleClose();
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -82,19 +95,15 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
...payload,
|
||||
})
|
||||
.then((res) => {
|
||||
mutate<IState[]>(
|
||||
STATE_LIST(projectId),
|
||||
(prevData) => {
|
||||
const newData = prevData?.map((item) => {
|
||||
if (item.id === res.id) {
|
||||
return res;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return newData;
|
||||
},
|
||||
false
|
||||
);
|
||||
mutate<IState[]>(STATE_LIST(projectId), (prevData) => {
|
||||
const newData = prevData?.map((item) => {
|
||||
if (item.id === res.id) {
|
||||
return res;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return newData;
|
||||
});
|
||||
handleClose();
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -107,33 +116,20 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (data === null) return;
|
||||
reset(data);
|
||||
}, [data, reset]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!data)
|
||||
reset({
|
||||
...defaultValues,
|
||||
group: selectedGroup ?? "backlog",
|
||||
});
|
||||
}, [selectedGroup, data, reset]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-x-2 p-2 bg-gray-50">
|
||||
<div className="flex-shrink-0 h-8 w-8">
|
||||
<Popover className="relative w-full h-full flex justify-center items-center bg-gray-200 rounded-xl">
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="flex items-center gap-x-2 bg-gray-50 p-2">
|
||||
<div className="h-8 w-8 flex-shrink-0">
|
||||
<Popover className="relative flex h-full w-full items-center justify-center rounded-xl bg-gray-200">
|
||||
{({ open }) => (
|
||||
<>
|
||||
<Popover.Button
|
||||
className={`group inline-flex items-center text-base font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 ${
|
||||
className={`group inline-flex items-center text-base font-medium focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
|
||||
open ? "text-gray-900" : "text-gray-500"
|
||||
}`}
|
||||
>
|
||||
{watch("color") && watch("color") !== "" && (
|
||||
<span
|
||||
className="w-4 h-4 rounded"
|
||||
className="h-4 w-4 rounded"
|
||||
style={{
|
||||
backgroundColor: watch("color") ?? "green",
|
||||
}}
|
||||
|
|
@ -150,7 +146,7 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
leaveFrom="opacity-100 translate-y-0"
|
||||
leaveTo="opacity-0 translate-y-1"
|
||||
>
|
||||
<Popover.Panel className="absolute top-full z-20 left-0 mt-3 px-2 w-screen max-w-xs sm:px-0">
|
||||
<Popover.Panel className="absolute top-full left-0 z-20 mt-3 w-screen max-w-xs px-2 sm:px-0">
|
||||
<Controller
|
||||
name="color"
|
||||
control={control}
|
||||
|
|
@ -168,6 +164,7 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
id="name"
|
||||
name="name"
|
||||
register={register}
|
||||
autoFocus
|
||||
placeholder="Enter state name"
|
||||
validations={{
|
||||
required: true,
|
||||
|
|
@ -201,9 +198,9 @@ export const CreateUpdateStateInline: React.FC<Props> = ({
|
|||
<Button theme="secondary" onClick={handleClose}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button theme="primary" disabled={isSubmitting} onClick={handleSubmit(onSubmit)}>
|
||||
<Button theme="primary" disabled={isSubmitting} type="submit">
|
||||
{isSubmitting ? "Loading..." : data ? "Update" : "Create"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@ import { TwitterPicker } from "react-color";
|
|||
|
||||
import { Dialog, Popover, Transition } from "@headlessui/react";
|
||||
// services
|
||||
import stateService from "lib/services/state.service";
|
||||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import type { IState } from "types";
|
||||
import stateService from "services/state.service";
|
||||
// fetch keys
|
||||
import { STATE_LIST } from "constants/fetch-keys";
|
||||
// constants
|
||||
import { GROUP_CHOICES } from "constants/";
|
||||
// ui
|
||||
import { Button, Input, Select, TextArea } from "ui";
|
||||
import { Button, Input, Select, TextArea } from "components/ui";
|
||||
// icons
|
||||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
// types
|
||||
import type { IState } from "types";
|
||||
type Props = {
|
||||
isOpen: boolean;
|
||||
projectId: string;
|
||||
|
|
@ -194,7 +194,7 @@ const CreateUpdateStateModal: React.FC<Props> = ({ isOpen, data, projectId, hand
|
|||
style={{
|
||||
backgroundColor: watch("color") ?? "green",
|
||||
}}
|
||||
></span>
|
||||
/>
|
||||
)}
|
||||
<ChevronDownIcon
|
||||
className={`ml-2 h-5 w-5 group-hover:text-gray-500 ${
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue