import React from "react"; import { useRouter } from "next/router"; import type { NextPage, NextPageContext } from "next"; import useSWR from "swr"; import { ChevronDownIcon, PlusIcon, RectangleStackIcon } from "@heroicons/react/24/outline"; import { Disclosure, Popover, Transition } from "@headlessui/react"; // layouts import AppLayout from "layouts/app-layout"; // hooks import useUser from "lib/hooks/useUser"; // ui import { Spinner, Breadcrumbs, BreadcrumbItem, EmptySpace, EmptySpaceItem, HeaderButton } from "ui"; // services import userService from "lib/services/user.service"; // hooks import useIssuesProperties from "lib/hooks/useIssuesProperties"; // types import { IIssue, Properties } from "types"; // lib import { requiredAuth } from "lib/auth"; // constants import { USER_ISSUE } from "constants/fetch-keys"; import { classNames, replaceUnderscoreIfSnakeCase } from "constants/common"; import SingleListIssue from "components/common/list-view/single-issue"; const MyIssues: NextPage = () => { const router = useRouter(); const { query: { workspaceSlug }, } = router; const { user } = useUser(); const { data: myIssues } = useSWR( user && workspaceSlug ? USER_ISSUE(workspaceSlug as string) : null, user && workspaceSlug ? () => userService.userIssues(workspaceSlug as string) : null ); // FIXME: remove this hard-coded value const [properties, setProperties] = useIssuesProperties( workspaceSlug ? (workspaceSlug as string) : undefined, undefined ); return ( } right={
{({ open }) => ( <> View

Properties

{Object.keys(properties).map((key) => ( ))}
)}
{ const e = new KeyboardEvent("keydown", { key: "i", ctrlKey: true, }); document.dispatchEvent(e); }} />
} >
{myIssues ? ( <> {myIssues.length > 0 ? (
{({ open }) => (

My Issues

{myIssues.length}

{myIssues.map((issue: IIssue) => ( // FIXME: add all functionalities {}} handleDeleteIssue={() => {}} issue={issue} properties={properties} removeIssue={() => {}} /> ))}
)}
) : (
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 const getServerSideProps = async (ctx: NextPageContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); const redirectAfterSignIn = ctx.req?.url; if (!user) { return { redirect: { destination: `/signin?next=${redirectAfterSignIn}`, permanent: false, }, }; } return { props: { user, }, }; }; export default MyIssues;