cal.pub0.org/pages/settings/billing.tsx

53 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-08-02 17:29:34 +00:00
import Head from "next/head";
import Shell from "../../components/Shell";
import SettingsShell from "../../components/Settings";
import prisma from "../../lib/prisma";
import { getSession } from "next-auth/client";
2021-06-16 12:44:25 +00:00
2021-08-02 17:29:34 +00:00
export default function Billing() {
2021-06-16 12:44:25 +00:00
return (
<Shell heading="Billing" subtitle="Manage your billing information and cancel your subscription.">
2021-06-16 12:44:25 +00:00
<Head>
<title>Billing | Calendso</title>
</Head>
<SettingsShell>
2021-07-30 23:05:38 +00:00
<div className="py-6 lg:pb-8 lg:col-span-9">
2021-06-16 12:44:25 +00:00
<div className="my-6">
<iframe
src="https://calendso.com/subscription-embed"
style={{ minHeight: 800, width: "100%", border: 0 }}
2021-06-16 12:44:25 +00:00
/>
</div>
</div>
</SettingsShell>
</Shell>
);
}
export async function getServerSideProps(context) {
2021-08-02 17:29:34 +00:00
const session = await getSession(context);
if (!session) {
return { redirect: { permanent: false, destination: "/auth/login" } };
}
2021-06-16 12:44:25 +00:00
2021-08-02 17:29:34 +00:00
const user = await prisma.user.findFirst({
where: {
email: session.user.email,
},
select: {
id: true,
username: true,
name: true,
email: true,
bio: true,
avatar: true,
timeZone: true,
weekStart: true,
},
});
2021-06-16 12:44:25 +00:00
2021-08-02 17:29:34 +00:00
return {
props: { user }, // will be passed to the page component as props
};
2021-07-30 23:05:38 +00:00
}