* chore: Remove all avatar/logo references * Updated user profile to only use avatarUrl * fix: minor style issue * chore: Remove redundant includeTeamLogo * fix: Use right avatar default in event type list * fix: placeholder avatar team profile, target * chore: Add logoUrl/avatarUrl to JWT * fix: Bunch of org avatar issues, fix members list * Fix logoUrl on org pages * More type fixes * Hopefully final type fixes * Another round of type fixes * fix: UserForm ts * fix: Handle as return types, not input types * fix: Remove profile and add avatarUrl * fix: notFound as const * fix: Seeder avatarUrl params * revert: Migration changes for easier recovery * fix: Add explicit type to builder as avatar is now set * Add logoUrl to unpublished entity * Avatar test out of scope here * fix: Use the new avatarUrl after save * chore: Removed getOrgAvatarUrl/getTeamAvatarUrl * fix: Update sidebar image immediately after change * Unable to safe unnamed user, so default * fix: Unpublished page, add organization test * Add more tests
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import type { GetServerSidePropsContext } from "next";
|
|
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
|
|
|
import { getLocale } from "@calcom/features/auth/lib/getLocale";
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
import prisma from "@calcom/prisma";
|
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
const { req } = context;
|
|
|
|
const session = await getServerSession({ req });
|
|
|
|
if (!session?.user?.id) {
|
|
return { redirect: { permanent: false, destination: "/auth/login" } };
|
|
}
|
|
|
|
const ssr = await ssrInit(context);
|
|
|
|
await ssr.viewer.me.prefetch();
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: {
|
|
id: session.user.id,
|
|
},
|
|
select: {
|
|
completedOnboarding: true,
|
|
teams: {
|
|
select: {
|
|
accepted: true,
|
|
team: {
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
logoUrl: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!user) {
|
|
throw new Error("User from session not found");
|
|
}
|
|
|
|
if (user.completedOnboarding) {
|
|
return { redirect: { permanent: false, destination: "/event-types" } };
|
|
}
|
|
const locale = await getLocale(context.req);
|
|
return {
|
|
props: {
|
|
...(await serverSideTranslations(locale, ["common"])),
|
|
trpcState: ssr.dehydrate(),
|
|
hasPendingInvites: user.teams.find((team) => team.accepted === false) ?? false,
|
|
},
|
|
};
|
|
};
|