added getinitialprops
This commit is contained in:
parent
87f7984d76
commit
ea75e8974d
1 changed files with 61 additions and 21 deletions
|
@ -1,9 +1,17 @@
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import Shell from '../../components/Shell';
|
import Shell from '../../components/Shell';
|
||||||
import SettingsShell from '../../components/Settings';
|
import SettingsShell from '../../components/Settings';
|
||||||
|
import prisma from '../../lib/prisma';
|
||||||
|
import {getSession, useSession} from 'next-auth/client';
|
||||||
|
|
||||||
export default function Billing() {
|
export default function Billing(props) {
|
||||||
return(
|
const [ session, loading ] = useSession();
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <p className="text-gray-400">Loading...</p>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<Shell heading="Billing">
|
<Shell heading="Billing">
|
||||||
<Head>
|
<Head>
|
||||||
<title>Billing | Calendso</title>
|
<title>Billing | Calendso</title>
|
||||||
|
@ -11,16 +19,48 @@ export default function Billing() {
|
||||||
<SettingsShell>
|
<SettingsShell>
|
||||||
<div className="py-6 px-4 sm:p-6 lg:pb-8 lg:col-span-9">
|
<div className="py-6 px-4 sm:p-6 lg:pb-8 lg:col-span-9">
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h2 className="text-lg leading-6 font-medium text-gray-900">Change your Subscription</h2>
|
<h2 className="text-lg leading-6 font-medium text-gray-900">
|
||||||
|
Change your Subscription
|
||||||
|
</h2>
|
||||||
<p className="mt-1 text-sm text-gray-500">
|
<p className="mt-1 text-sm text-gray-500">
|
||||||
Cancel, update credit card or change plan
|
Cancel, update credit card or change plan
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="my-6">
|
<div className="my-6">
|
||||||
<iframe src="https://calendso.com/subscription-embed" style={{width: "100%", border: 0}} />
|
<iframe
|
||||||
|
src="https://calendso.com/subscription-embed"
|
||||||
|
style={{ width: "100%", border: 0 }}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</SettingsShell>
|
</SettingsShell>
|
||||||
</Shell>
|
</Shell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getServerSideProps(context) {
|
||||||
|
const session = await getSession(context);
|
||||||
|
if (!session) {
|
||||||
|
return { redirect: { permanent: false, destination: '/auth/login' } };
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {user}, // will be passed to the page component as props
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue