import React, { useCallback } from "react"; import Link from "next/link"; import { useRouter } from "next/router"; import useSWR, { mutate } from "swr"; // services import stateService from "services/state.service"; import issuesService from "services/issues.service"; // components import { DueDateSelect, PrioritySelect, StateSelect } from "components/core/select"; // ui import { AssigneesList } from "components/ui/avatar"; import { CustomMenu } from "components/ui"; // types import { IIssue, Properties } from "types"; // fetch-keys import { STATE_LIST, 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 { data: states } = useSWR( workspaceSlug && projectId ? STATE_LIST(projectId) : null, workspaceSlug && projectId ? () => stateService.getStates(workspaceSlug as string, projectId) : null ); 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
); };