2023-03-30 11:34:41 +00:00
|
|
|
import { GetServerSidePropsContext } from "next";
|
|
|
|
|
|
|
|
import useSWR from "swr";
|
|
|
|
|
|
|
|
// services
|
|
|
|
import userService from "services/user.service";
|
|
|
|
// lib
|
|
|
|
import { requiredAuth } from "lib/auth";
|
|
|
|
// layouts
|
|
|
|
import AppLayout from "layouts/app-layout";
|
|
|
|
// ui
|
|
|
|
import { Loader } from "components/ui";
|
|
|
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
2023-03-31 17:30:28 +00:00
|
|
|
import { Feeds } from "components/core";
|
2023-03-30 11:34:41 +00:00
|
|
|
// fetch-keys
|
|
|
|
import { USER_ACTIVITY } from "constants/fetch-keys";
|
|
|
|
|
|
|
|
const ProfileActivity = () => {
|
|
|
|
const { data: userActivity } = useSWR(USER_ACTIVITY, () => userService.getUserActivity());
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AppLayout
|
|
|
|
meta={{
|
|
|
|
title: "Plane - My Profile",
|
|
|
|
}}
|
|
|
|
breadcrumbs={
|
|
|
|
<Breadcrumbs>
|
|
|
|
<BreadcrumbItem title="My Profile Activity" />
|
|
|
|
</Breadcrumbs>
|
|
|
|
}
|
|
|
|
settingsLayout
|
|
|
|
profilePage
|
|
|
|
>
|
|
|
|
{userActivity ? (
|
2023-03-31 17:30:28 +00:00
|
|
|
userActivity.results.length > 0 ? (
|
|
|
|
<Feeds activities={userActivity.results} />
|
|
|
|
) : null
|
2023-03-30 11:34:41 +00:00
|
|
|
) : (
|
|
|
|
<Loader className="space-y-5">
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
</Loader>
|
|
|
|
)}
|
|
|
|
</AppLayout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
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 ProfileActivity;
|