chore: refactored and resolved build issues on the issues and issue detail page (#3340)

* fix: handled undefined issue_id in list layout

* dev: issue detail store and optimization

* dev: issue filter and list operations

* fix: typo on labels update

* dev: Handled all issues in the list layout in project issues

* dev: handled kanban and auick add issue in swimlanes

* chore: fixed peekoverview in kanban

* chore: fixed peekoverview in calendar

* chore: fixed peekoverview in gantt

* chore: updated quick add in the gantt chart

* chore: handled issue detail properties and resolved build issues

---------

Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
This commit is contained in:
guru_sainath 2024-01-10 20:09:45 +05:30 committed by sriram veeraghanta
parent e6b31e2550
commit 4611ec0b83
112 changed files with 3303 additions and 2560 deletions

View file

@ -1,13 +1,17 @@
import { FC, useMemo } from "react";
// hooks
import { useApplication, useIssueDetail } from "hooks/store";
import { useIssueDetail } from "hooks/store";
import useToast from "hooks/use-toast";
// components
import { IssueAttachmentUpload } from "./attachment-upload";
import { IssueAttachmentsList } from "./attachments-list";
export type TIssueAttachmentRoot = {
isEditable: boolean;
workspaceSlug: string;
projectId: string;
issueId: string;
is_archived: boolean;
is_editable: boolean;
};
export type TAttachmentOperations = {
@ -17,20 +21,17 @@ export type TAttachmentOperations = {
export const IssueAttachmentRoot: FC<TIssueAttachmentRoot> = (props) => {
// props
const { isEditable } = props;
const { workspaceSlug, projectId, issueId, is_archived, is_editable } = props;
// hooks
const {
router: { workspaceSlug, projectId },
} = useApplication();
const { peekIssue, createAttachment, removeAttachment } = useIssueDetail();
const { createAttachment, removeAttachment } = useIssueDetail();
const { setToastAlert } = useToast();
const handleAttachmentOperations: TAttachmentOperations = useMemo(
() => ({
create: async (data: FormData) => {
try {
if (!workspaceSlug || !projectId || !peekIssue?.issueId) throw new Error("Missing required fields");
await createAttachment(workspaceSlug, projectId, peekIssue?.issueId, data);
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing required fields");
await createAttachment(workspaceSlug, projectId, issueId, data);
setToastAlert({
message: "The attachment has been successfully uploaded",
type: "success",
@ -46,8 +47,8 @@ export const IssueAttachmentRoot: FC<TIssueAttachmentRoot> = (props) => {
},
remove: async (attachmentId: string) => {
try {
if (!workspaceSlug || !projectId || !peekIssue?.issueId) throw new Error("Missing required fields");
await removeAttachment(workspaceSlug, projectId, peekIssue?.issueId, attachmentId);
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing required fields");
await removeAttachment(workspaceSlug, projectId, issueId, attachmentId);
setToastAlert({
message: "The attachment has been successfully removed",
type: "success",
@ -62,14 +63,18 @@ export const IssueAttachmentRoot: FC<TIssueAttachmentRoot> = (props) => {
}
},
}),
[workspaceSlug, projectId, peekIssue, createAttachment, removeAttachment, setToastAlert]
[workspaceSlug, projectId, issueId, createAttachment, removeAttachment, setToastAlert]
);
return (
<div className="relative py-3 space-y-3">
<h3 className="text-lg">Attachments</h3>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
<IssueAttachmentUpload disabled={isEditable} handleAttachmentOperations={handleAttachmentOperations} />
<IssueAttachmentUpload
workspaceSlug={workspaceSlug}
disabled={is_editable}
handleAttachmentOperations={handleAttachmentOperations}
/>
<IssueAttachmentsList handleAttachmentOperations={handleAttachmentOperations} />
</div>
</div>