perf: Remove ssrInit completely (#20439)
* remove ssrInit completely * remove instances of dehydratedState * fix * refactor * fix type checks * fix linting * Refactor * Refactor * remove log
This commit is contained in:
1 parent
b5b4134b75
commit
75c79f76c8
30 files changed
+70
-209
No files matched your search
@@ -1,9 +1,4 @@
|
||||
import type {
|
||||
AppGetServerSidePropsContext,
|
||||
AppPrisma,
|
||||
AppSsrInit,
|
||||
AppUser,
|
||||
} from "@calcom/types/AppGetServerSideProps";
|
||||
import type { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps";
|
||||
|
||||
import { enrichFormWithMigrationData } from "../enrichFormWithMigrationData";
|
||||
import { getSerializableForm } from "../lib/getSerializableForm";
|
||||
@@ -11,11 +6,8 @@ import { getSerializableForm } from "../lib/getSerializableForm";
|
||||
export const getServerSidePropsForSingleFormView = async function getServerSidePropsForSingleFormView(
|
||||
context: AppGetServerSidePropsContext,
|
||||
prisma: AppPrisma,
|
||||
user: AppUser,
|
||||
ssrInit: AppSsrInit
|
||||
user: AppUser
|
||||
) {
|
||||
const ssr = await ssrInit(context);
|
||||
|
||||
if (!user) {
|
||||
return {
|
||||
redirect: {
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
|
||||
import type {
|
||||
AppGetServerSidePropsContext,
|
||||
AppPrisma,
|
||||
AppSsrInit,
|
||||
AppUser,
|
||||
} from "@calcom/types/AppGetServerSideProps";
|
||||
import type { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps";
|
||||
|
||||
export const getServerSideProps = async function getServerSideProps(
|
||||
context: AppGetServerSidePropsContext,
|
||||
prisma: AppPrisma,
|
||||
user: AppUser,
|
||||
ssrInit: AppSsrInit
|
||||
user: AppUser
|
||||
) {
|
||||
if (!user) {
|
||||
return {
|
||||
@@ -20,15 +13,7 @@ export const getServerSideProps = async function getServerSideProps(
|
||||
},
|
||||
};
|
||||
}
|
||||
const ssr = await ssrInit(context);
|
||||
|
||||
const filters = getTeamsFiltersFromQuery(context.query);
|
||||
|
||||
await ssr.viewer.appRoutingForms.forms.prefetch({
|
||||
filters,
|
||||
});
|
||||
// Prefetch this so that New Button is immediately available
|
||||
await ssr.viewer.teamsAndUserProfilesQuery.prefetch();
|
||||
return {
|
||||
props: {},
|
||||
};
|
||||
|
||||
@@ -8,8 +8,6 @@ import { paymentDataSelect } from "@calcom/prisma/selects/payment";
|
||||
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
|
||||
|
||||
import { ssrInit } from "../../../../../apps/web/server/lib/ssr";
|
||||
|
||||
export type PaymentPageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
|
||||
const querySchema = z.object({
|
||||
@@ -17,8 +15,6 @@ const querySchema = z.object({
|
||||
});
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const ssr = await ssrInit(context);
|
||||
|
||||
const { uid } = querySchema.parse(context.query);
|
||||
const rawPayment = await prisma.payment.findFirst({
|
||||
where: {
|
||||
@@ -79,7 +75,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
metadata: EventTypeMetaDataSchema.parse(eventType.metadata),
|
||||
},
|
||||
booking,
|
||||
trpcState: ssr.dehydrate(),
|
||||
payment,
|
||||
clientSecret: getClientSecretFromPayment(payment),
|
||||
profile,
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useAtomsEventTypePaymentInfo = ({
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY, uid],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<Omit<PaymentPageProps, "trpcState">>>(pathname).then((res) => {
|
||||
return http?.get<ApiResponse<PaymentPageProps>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
onEventTypePaymentInfoSuccess?.();
|
||||
return res.data.data;
|
||||
|
||||
@@ -26,8 +26,8 @@ export const PaymentForm = ({
|
||||
onEventTypePaymentInfoFailure,
|
||||
}: {
|
||||
paymentUid: string;
|
||||
onPaymentSuccess?: (input: Omit<PaymentPageProps, "trpcState">) => void;
|
||||
onPaymentCancellation?: (input: Omit<PaymentPageProps, "trpcState">) => void;
|
||||
onPaymentSuccess?: (input: PaymentPageProps) => void;
|
||||
onPaymentCancellation?: (input: PaymentPageProps) => void;
|
||||
onEventTypePaymentInfoSuccess?: () => void;
|
||||
onEventTypePaymentInfoFailure?: () => void;
|
||||
}) => {
|
||||
|
||||
@@ -11,8 +11,8 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
const StripePaymentComponent = (
|
||||
props: Props & {
|
||||
onPaymentSuccess?: (input: Omit<PaymentPageProps, "trpcState">) => void;
|
||||
onPaymentCancellation?: (input: Omit<PaymentPageProps, "trpcState">) => void;
|
||||
onPaymentSuccess?: (input: PaymentPageProps) => void;
|
||||
onPaymentCancellation?: (input: PaymentPageProps) => void;
|
||||
}
|
||||
) => {
|
||||
const { t } = useLocale();
|
||||
@@ -82,7 +82,7 @@ const StripePaymentComponent = (
|
||||
});
|
||||
} else {
|
||||
setState({ status: "idle" });
|
||||
props.onPaymentSuccess?.(props as unknown as Omit<PaymentPageProps, "trpcState">);
|
||||
props.onPaymentSuccess?.(props as unknown as PaymentPageProps);
|
||||
if (props.location) {
|
||||
if (props.location.includes("integration")) {
|
||||
params.location = t("web_conferencing_details_to_follow");
|
||||
@@ -93,7 +93,7 @@ const StripePaymentComponent = (
|
||||
}
|
||||
}}
|
||||
onCancel={() => {
|
||||
props.onPaymentCancellation?.(props as unknown as Omit<PaymentPageProps, "trpcState">);
|
||||
props.onPaymentCancellation?.(props as unknown as PaymentPageProps);
|
||||
}}
|
||||
onPaymentElementChange={() => {
|
||||
setState({ status: "idle" });
|
||||
@@ -105,8 +105,8 @@ const StripePaymentComponent = (
|
||||
const StripePaymentForm = (
|
||||
props: Props & {
|
||||
uid: string;
|
||||
onPaymentSuccess?: (input: Omit<PaymentPageProps, "trpcState">) => void;
|
||||
onPaymentCancellation?: (input: Omit<PaymentPageProps, "trpcState">) => void;
|
||||
onPaymentSuccess?: (input: PaymentPageProps) => void;
|
||||
onPaymentCancellation?: (input: PaymentPageProps) => void;
|
||||
}
|
||||
) => {
|
||||
const stripePromise = getStripe(props.payment.data.stripe_publishable_key as any);
|
||||
|
||||
+2
-5
@@ -3,17 +3,14 @@ import type { CalendsoSessionUser } from "next-auth";
|
||||
|
||||
import type prisma from "@calcom/prisma";
|
||||
|
||||
import type { ssrInit } from "@server/lib/ssr";
|
||||
|
||||
export type AppUser = CalendsoSessionUser | undefined;
|
||||
export type AppPrisma = typeof prisma;
|
||||
export type AppGetServerSidePropsContext = GetServerSidePropsContext<{
|
||||
pages: string[];
|
||||
}>;
|
||||
export type AppSsrInit = ssrInit;
|
||||
|
||||
export type AppGetServerSideProps = (
|
||||
context: AppGetServerSidePropsContext,
|
||||
prisma: AppPrisma,
|
||||
user: AppUser,
|
||||
ssrInit: AppSsrInit
|
||||
user: AppUser
|
||||
) => GetServerSidePropsResult;
|
||||
Reference in new issue
Block a user