// next import type { NextPage } from "next"; import Link from "next/link"; // react import React from "react"; // layouts import AdminLayout from "layouts/AdminLayout"; // swr import useSWR from "swr"; // hooks import useUser from "lib/hooks/useUser"; // hoc import withAuthWrapper from "lib/hoc/withAuthWrapper"; // fetch keys import { USER_ISSUE } from "constants/fetch-keys"; // services import userService from "lib/services/user.service"; // ui import { Spinner } from "ui"; // icons import { ArrowRightIcon } from "@heroicons/react/24/outline"; // types import type { IIssue } from "types"; const Workspace: NextPage = () => { const { user, activeWorkspace, projects } = useUser(); const { data: myIssues } = useSWR( user ? USER_ISSUE : null, user ? () => userService.userIssues() : null ); const cards = [ { id: 1, numbers: projects?.length ?? 0, title: "Projects", }, { id: 3, numbers: myIssues?.length ?? 0, title: "Issues", }, ]; const hours = new Date().getHours(); return (
{user ? (
Good{" "} {hours >= 4 && hours < 12 ? "Morning" : hours >= 12 && hours < 17 ? "Afternoon" : "Evening"} , {user.first_name}!!
) : (
)} {/* dashboard */}
{cards.map(({ id, title, numbers }) => (

#{title}

{numbers}

))}
{myIssues ? ( myIssues.length > 0 ? ( {myIssues?.map((issue, index) => ( ))}
ISSUE KEY STATUS
{issue.name} {issue.sequence_id} {issue.state_detail.name ?? "None"}
) : (

No Issues Found

) ) : (
)}

PROJECTS

{projects && activeWorkspace ? ( projects.length > 0 ? ( projects .sort((a, b) => Date.parse(`${a.updated_at}`) - Date.parse(`${b.updated_at}`)) .map( (project, index) => index < 3 && (

{project.name}

) ) ) : (

No projects has been create for this workspace.

) ) : (
)}
); }; export default withAuthWrapper(Workspace);