Files
calendar/packages/app-store/alby/pages/setup/_getServerSideProps.tsx
T
Benny JooGitHubbenny@cal.com <sldisek783@gmail.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
76bba1ca05 refactor: remove circular dependency between appstore and trpc (#23768)
* mv PaymentPage to web

* mv 2 more components to web

* refactor

* update imports

* mv

* revert

* fix

* fix

* update

* migrate relevant test too

* move setup components to web from appstore

* move wipemycalother

* mv

* fix typechecks

* mv more routing forms components

* fix

* fix

* fix

* fix: resolve type errors in SingleForm.tsx after migration

- Updated SingleFormComponentProps type to include enriched form properties
- Added proper typing for user, team, nonOrgUsername, nonOrgTeamslug, userOrigin, teamOrigin
- Fixes type errors that occurred after migrating SingleForm.tsx from packages/app-store/routing-forms/components/
- Resolves both SingleForm.tsx and TestForm.tsx type errors

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* delete

* refactors

* fix

* fix

* fix

* remove usage of trpc client from OmniInstallAppButton.tsx

* fix test

* import only type

* fix test

* remove trpc package from appstore package.json

* remove remaining trpc usage

* update test

* fix type checks

* fix errors

* fix

* make it error

* nit

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-09-14 12:51:05 +00:00

61 lines
1.5 KiB
TypeScript

import type { GetServerSidePropsContext } from "next";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import prisma from "@calcom/prisma";
import { getAlbyKeys } from "../../lib/getAlbyKeys";
export interface IAlbySetupProps {
email: string | null;
lightningAddress: string | null;
clientId: string;
clientSecret: string;
}
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
const notFound = { notFound: true } as const;
if (typeof ctx.params?.slug !== "string") return notFound;
const { req } = ctx;
const session = await getServerSession({ req });
if (!session?.user?.id) {
const redirect = { redirect: { permanent: false, destination: "/auth/login" } } as const;
return redirect;
}
const credentials = await prisma.credential.findFirst({
where: {
type: "alby_payment",
userId: session?.user.id,
},
});
const { client_id: clientId, client_secret: clientSecret } = await getAlbyKeys();
const props: IAlbySetupProps = {
email: null,
lightningAddress: null,
clientId,
clientSecret,
};
if (credentials?.key) {
const { account_lightning_address, account_email } = credentials.key as {
account_lightning_address?: string;
account_email?: string;
};
if (account_lightning_address) {
props.lightningAddress = account_lightning_address;
}
if (account_email) {
props.email = account_email;
}
}
return {
props,
};
};