import React, { useCallback } from "react"; import Link from "next/link"; import { useRouter } from "next/router"; import { mutate } from "swr"; // services import issuesService from "services/issues.service"; // components import { ViewDueDateSelect, ViewPrioritySelect, ViewStateSelect, } from "components/issues/view-select"; // ui import { AssigneesList } from "components/ui/avatar"; import { CustomMenu } from "components/ui"; // types import { IIssue, Properties } from "types"; // fetch-keys import { USER_ISSUE } from "constants/fetch-keys"; type Props = { issue: IIssue; properties: Properties; projectId: string; handleDeleteIssue: () => void; }; export const MyIssuesListItem: React.FC = ({ issue, properties, projectId, handleDeleteIssue, }) => { const router = useRouter(); const { workspaceSlug } = router.query; const partialUpdateIssue = useCallback( (formData: Partial) => { if (!workspaceSlug) return; mutate( USER_ISSUE(workspaceSlug as string), (prevData) => prevData?.map((p) => { if (p.id === issue.id) return { ...p, ...formData }; return p; }), false ); issuesService .patchIssue(workspaceSlug as string, projectId as string, issue.id, formData) .then((res) => { mutate(USER_ISSUE(workspaceSlug as string)); }) .catch((error) => { console.log(error); }); }, [workspaceSlug, projectId, issue] ); const isNotAllowed = false; return (
{properties?.key && ( {issue.project_detail?.identifier}-{issue.sequence_id} )} {issue.name}
{properties.priority && ( )} {properties.state && ( )} {properties.due_date && ( )} {properties.sub_issue_count && (
{issue?.sub_issues_count} {issue?.sub_issues_count === 1 ? "sub-issue" : "sub-issues"}
)} {properties.assignee && (
)} Delete permanently
); };