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"; // helpers import { timeAgo } from "helpers/date-time.helper"; // fetch-keys import { USER_ACTIVITY } from "constants/fetch-keys"; const ProfileActivity = () => { const { data: userActivity } = useSWR(USER_ACTIVITY, () => userService.getUserActivity()); return ( } settingsLayout profilePage > {userActivity ? (
{userActivity.results.length > 0 ? userActivity.results.map((activity) => (

{activity.comment}

{timeAgo(activity.created_at)}
)) : null}
) : ( )}
); }; 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;