import React from "react"; import Link from "next/link"; import { useRouter } from "next/router"; // lib import { requiredAuth } from "lib/auth"; // layouts import AppLayout from "layouts/app-layout"; // hooks import useProjects from "hooks/use-projects"; import useWorkspaceDetails from "hooks/use-workspace-details"; import useIssues from "hooks/use-issues"; // components import { WorkspaceHomeCardsList, WorkspaceHomeGreetings } from "components/workspace"; // ui import { Spinner, Tooltip } from "components/ui"; // icons import { ArrowRightIcon, CalendarDaysIcon, ClipboardDocumentListIcon, } from "@heroicons/react/24/outline"; import { LayerDiagonalIcon } from "components/icons"; import { getPriorityIcon } from "components/icons/priority-icon"; // helpers import { renderShortNumericDateFormat, findHowManyDaysLeft } from "helpers/date-time.helper"; import { addSpaceIfCamelCase } from "helpers/string.helper"; import { groupBy } from "helpers/array.helper"; // types import type { NextPage, GetServerSidePropsContext } from "next"; const WorkspacePage: NextPage = () => { // router const router = useRouter(); const { workspaceSlug } = router.query; // API Fetching const { myIssues } = useIssues(workspaceSlug?.toString()); const { projects, recentProjects } = useProjects(); const {} = useWorkspaceDetails(); const groupedIssues = { backlog: [], unstarted: [], started: [], cancelled: [], completed: [], ...groupBy(myIssues ?? [], "state_detail.group"), }; return (
{/** TODO: Convert the below mentioned HTML Content to separate component */}
{myIssues ? ( myIssues.length > 0 ? (

My Issues

{myIssues.length}

{myIssues.map((issue) => (
{getPriorityIcon(issue.priority)}
{addSpaceIfCamelCase(issue.state_detail.name)}
{issue.target_date ? renderShortNumericDateFormat(issue.target_date) : "N/A"}
))}
) : (

No issues found. Create a new issue with{" "}
C
.

) ) : (
)}

Recent Projects

{recentProjects && workspaceSlug ? ( recentProjects.length > 0 ? ( recentProjects.map((project) => (
{project.icon ? ( {String.fromCodePoint(parseInt(project.icon))} ) : ( {project?.name.charAt(0)} )}

{project.name}

)) ) : (

No projects has been create for this workspace.

) ) : (
)}
); }; export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const user = await requiredAuth(ctx.req?.headers.cookie); const redirectAfterSignIn = ctx.resolvedUrl; if (!user) { return { redirect: { destination: `/signin?next=${redirectAfterSignIn}`, permanent: false, }, }; } return { props: { user, }, }; }; export default WorkspacePage;