2024-03-06 08:54:36 +00:00
|
|
|
import { ReactElement, useState } from "react";
|
2024-01-23 15:15:44 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-05-08 17:31:20 +00:00
|
|
|
// ui
|
2024-03-06 13:09:14 +00:00
|
|
|
import { Button } from "@plane/ui";
|
2024-05-08 17:31:20 +00:00
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { PageHead } from "@/components/core";
|
2024-05-08 17:31:20 +00:00
|
|
|
import { SidebarHamburgerToggle } from "@/components/core/sidebar";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { ProfileActivityListPage } from "@/components/profile";
|
2024-05-08 17:31:20 +00:00
|
|
|
//hooks
|
|
|
|
import { useAppTheme } from "@/hooks/store";
|
2023-11-24 06:46:37 +00:00
|
|
|
// layouts
|
2024-03-19 14:38:35 +00:00
|
|
|
import { ProfileSettingsLayout } from "@/layouts/settings-layout";
|
2023-11-24 06:46:37 +00:00
|
|
|
// type
|
2024-03-19 14:38:35 +00:00
|
|
|
import { NextPageWithLayout } from "@/lib/types";
|
2023-11-24 06:46:37 +00:00
|
|
|
|
2024-03-06 08:54:36 +00:00
|
|
|
const PER_PAGE = 100;
|
2023-11-24 06:46:37 +00:00
|
|
|
|
2024-01-23 15:15:44 +00:00
|
|
|
const ProfileActivityPage: NextPageWithLayout = observer(() => {
|
2024-03-06 08:54:36 +00:00
|
|
|
// states
|
|
|
|
const [pageCount, setPageCount] = useState(1);
|
|
|
|
const [totalPages, setTotalPages] = useState(0);
|
|
|
|
const [resultsCount, setResultsCount] = useState(0);
|
2024-01-23 15:15:44 +00:00
|
|
|
// store hooks
|
2024-05-08 17:31:20 +00:00
|
|
|
const { toggleSidebar } = useAppTheme();
|
2023-11-24 06:46:37 +00:00
|
|
|
|
2024-03-06 08:54:36 +00:00
|
|
|
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(
|
|
|
|
<ProfileActivityListPage
|
|
|
|
key={i}
|
|
|
|
cursor={`${PER_PAGE}:${i}:0`}
|
|
|
|
perPage={PER_PAGE}
|
|
|
|
updateResultsCount={updateResultsCount}
|
|
|
|
updateTotalPages={updateTotalPages}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2024-03-22 15:16:13 +00:00
|
|
|
const isLoadMoreVisible = pageCount < totalPages && resultsCount !== 0;
|
|
|
|
|
2023-11-24 06:46:37 +00:00
|
|
|
return (
|
2024-02-20 08:06:38 +00:00
|
|
|
<>
|
|
|
|
<PageHead title="Profile - Activity" />
|
2024-04-24 09:50:32 +00:00
|
|
|
<section className="mx-auto mt-5 md:mt-16 h-full w-full flex flex-col overflow-hidden px-5 md:px-8 pb-8 lg:w-3/5">
|
|
|
|
<div className="flex items-center border-b border-custom-border-100 gap-4 pb-3.5">
|
2024-05-08 17:31:20 +00:00
|
|
|
<SidebarHamburgerToggle onClick={() => toggleSidebar()} />
|
2024-02-20 08:06:38 +00:00
|
|
|
<h3 className="text-xl font-medium">Activity</h3>
|
|
|
|
</div>
|
2024-05-08 17:31:20 +00:00
|
|
|
<div className="vertical-scrollbar scrollbar-md flex h-full w-full flex-col overflow-y-auto">
|
2024-03-06 08:54:36 +00:00
|
|
|
{activityPages}
|
2024-03-22 15:16:13 +00:00
|
|
|
{isLoadMoreVisible && (
|
2024-05-08 17:31:20 +00:00
|
|
|
<div className="flex w-full items-center justify-center text-xs">
|
2024-03-06 08:54:36 +00:00
|
|
|
<Button variant="accent-primary" size="sm" onClick={handleLoadMore}>
|
|
|
|
Load more
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2024-02-20 08:06:38 +00:00
|
|
|
</section>
|
|
|
|
</>
|
2023-11-24 06:46:37 +00:00
|
|
|
);
|
2024-01-23 15:15:44 +00:00
|
|
|
});
|
2023-11-24 06:46:37 +00:00
|
|
|
|
|
|
|
ProfileActivityPage.getLayout = function getLayout(page: ReactElement) {
|
2023-11-29 08:18:07 +00:00
|
|
|
return <ProfileSettingsLayout>{page}</ProfileSettingsLayout>;
|
2023-11-24 06:46:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ProfileActivityPage;
|