import { ReactElement, useState } from "react"; import { observer } from "mobx-react"; import { useRouter } from "next/router"; // hooks import { Button } from "@plane/ui"; import { UserProfileHeader } from "@/components/headers"; import { DownloadActivityButton, WorkspaceActivityListPage } from "@/components/profile"; import { EUserWorkspaceRoles } from "@/constants/workspace"; import { useUser } from "@/hooks/store"; // layouts import { AppLayout } from "@/layouts/app-layout"; import { ProfileAuthWrapper } from "@/layouts/user-profile-layout"; // components // ui // types import { NextPageWithLayout } from "@/lib/types"; // constants const PER_PAGE = 100; const ProfileActivityPage: NextPageWithLayout = observer(() => { // states const [pageCount, setPageCount] = useState(1); const [totalPages, setTotalPages] = useState(0); const [resultsCount, setResultsCount] = useState(0); // router const router = useRouter(); const { userId } = router.query; // store hooks const { currentUser, membership: { currentWorkspaceRole }, } = useUser(); const updateTotalPages = (count: number) => setTotalPages(count); const updateResultsCount = (count: number) => setResultsCount(count); const handleLoadMore = () => setPageCount((prev) => prev + 1); const activityPages: JSX.Element[] = []; for (let i = 0; i < pageCount; i++) activityPages.push( ); const canDownloadActivity = currentUser?.id === userId && !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER; return (

Recent activity

{canDownloadActivity && }
{activityPages} {pageCount < totalPages && resultsCount !== 0 && (
)}
); }); ProfileActivityPage.getLayout = function getLayout(page: ReactElement) { return ( }> {page} ); }; export default ProfileActivityPage;