import React from "react"; import { useRouter } from "next/router"; import Link from "next/link"; import useSWR from "swr"; // layouts import { WorkspaceAuthorizationLayout } from "layouts/auth-layout"; // services import userService from "services/user.service"; // components import { ProfileNavbar, ProfilePriorityDistribution, ProfileSidebar, ProfileStateDistribution, ProfileStats, ProfileWorkload, } from "components/profile"; // ui import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import { Icon, Loader } from "components/ui"; // helpers import { activityDetails } from "helpers/activity.helper"; import { timeAgo } from "helpers/date-time.helper"; // types import type { NextPage } from "next"; import { IUserStateDistribution, TStateGroups } from "types"; // constants import { USER_PROFILE_DATA, USER_PROFILE_ACTIVITY } from "constants/fetch-keys"; import { GROUP_CHOICES } from "constants/project"; const ProfileOverview: NextPage = () => { const router = useRouter(); const { workspaceSlug, userId } = router.query; const { data: userProfile } = useSWR( workspaceSlug && userId ? USER_PROFILE_DATA(workspaceSlug.toString(), userId.toString()) : null, workspaceSlug && userId ? () => userService.getUserProfileData(workspaceSlug.toString(), userId.toString()) : null ); const { data: userProfileActivity } = useSWR( workspaceSlug && userId ? USER_PROFILE_ACTIVITY(workspaceSlug.toString(), userId.toString()) : null, workspaceSlug && userId ? () => userService.getUserProfileActivity(workspaceSlug.toString(), userId.toString()) : null ); const stateDistribution: IUserStateDistribution[] = Object.keys(GROUP_CHOICES).map((key) => { const group = userProfile?.state_distribution.find((g) => g.state_group === key); if (group) return group; else return { state_group: key as TStateGroups, state_count: 0 }; }); return ( } >

Recent Activity

{userProfileActivity ? (
{userProfileActivity.results.map((activity) => (
{activity.actor_detail.avatar && activity.actor_detail.avatar !== "" ? ( {activity.actor_detail.first_name} ) : (
{activity.actor_detail.first_name.charAt(0)}
)}

{activity.actor_detail.first_name} {activity.actor_detail.last_name}{" "} {activity.field ? ( activityDetails[activity.field]?.message(activity as any) ) : ( created this{" "} Issue )}

{timeAgo(activity.created_at)}

))}
) : ( )}
); }; export default ProfileOverview;