// react import React, { useState } from "react"; // next import type { NextPage } from "next"; // swr import useSWR from "swr"; // layouts import AppLayout from "layouts/AppLayout"; // hooks import useUser from "lib/hooks/useUser"; // ui import { Spinner } from "ui"; import { BreadcrumbItem, Breadcrumbs } from "ui/Breadcrumbs"; import { EmptySpace, EmptySpaceItem } from "ui/EmptySpace"; import HeaderButton from "ui/HeaderButton"; // constants import { USER_ISSUE } from "constants/fetch-keys"; import { classNames } from "constants/common"; // services import userService from "lib/services/user.service"; import issuesServices from "lib/services/issues.services"; // hoc import withAuth from "lib/hoc/withAuthWrapper"; // components import ChangeStateDropdown from "components/project/issues/my-issues/ChangeStateDropdown"; // icons import { ChevronDownIcon, PlusIcon, RectangleStackIcon } from "@heroicons/react/24/outline"; // types import { IIssue } from "types"; import Link from "next/link"; import { Menu, Transition } from "@headlessui/react"; const MyIssues: NextPage = () => { const [selectedWorkspace, setSelectedWorkspace] = useState(null); const { user, workspaces } = useUser(); const { data: myIssues, mutate: mutateMyIssues } = useSWR( user ? USER_ISSUE : null, user ? () => userService.userIssues() : null ); const updateMyIssues = ( workspaceSlug: string, projectId: string, issueId: string, issue: Partial ) => { mutateMyIssues((prevData) => { return prevData?.map((prevIssue) => { if (prevIssue.id === issueId) { return { ...prevIssue, ...issue, state_detail: { ...prevIssue.state_detail, ...issue.state_detail, }, }; } return prevIssue; }); }, false); issuesServices .patchIssue(workspaceSlug, projectId, issueId, issue) .then((response) => { console.log(response); }) .catch((error) => { console.log(error); }); }; const handleWorkspaceChange = (workspaceId: string | null) => { setSelectedWorkspace(workspaceId); }; return (
{myIssues ? ( <> {myIssues.length > 0 ? ( <>

My Issues

{workspaces?.find((w) => w.id === selectedWorkspace)?.name ?? "All workspaces"}
{({ active }) => ( )} {workspaces && workspaces.map((workspace) => ( {({ active }) => ( )} ))}
{ const e = new KeyboardEvent("keydown", { key: "i", ctrlKey: true, }); document.dispatchEvent(e); }} />
{myIssues .filter((i) => selectedWorkspace ? i.workspace === selectedWorkspace : true ) .map((myIssue, index) => ( ))}
NAME DESCRIPTION PROJECT PRIORITY STATUS
{myIssue.name} {/* {myIssue.description} */} {myIssue.project_detail?.name}
{`(${myIssue.project_detail?.identifier}-${myIssue.sequence_id})`}
{myIssue.priority}
) : (
Use{" "}
Ctrl/Command + I
{" "} shortcut to create a new issue } Icon={PlusIcon} action={() => { const e = new KeyboardEvent("keydown", { key: "i", ctrlKey: true, }); document.dispatchEvent(e); }} />
)} ) : (
)}
); }; export default withAuth(MyIssues);