Skip to content

Commit d520a58

Browse files
committed
[portal] Create the customer portal
1 parent 9c9e634 commit d520a58

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

src/app/billing/page.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { auth } from '@/lib/auth';
2+
import { freemius } from '@/lib/freemius';
3+
import { headers } from 'next/headers';
4+
import { redirect } from 'next/navigation';
5+
import { CustomerPortal } from '@/react-starter/components/customer-portal';
6+
import FSCheckoutProvider from '@/components/fs-checkout';
7+
import AppMain, { AppContent } from '@/components/app-main';
8+
9+
export default async function Billing() {
10+
const session = await auth.api.getSession({
11+
headers: await headers(),
12+
});
13+
14+
if (!session) {
15+
redirect('/login');
16+
}
17+
18+
const checkout = await freemius.checkout.create({
19+
user: session?.user,
20+
isSandbox: process.env.NODE_ENV !== 'production',
21+
});
22+
23+
return (
24+
<AppMain title="Billing" isLoggedIn={true}>
25+
<AppContent>
26+
<FSCheckoutProvider checkout={checkout.serialize()}>
27+
<CustomerPortal endpoint={process.env.NEXT_PUBLIC_APP_URL! + '/api/portal'} />
28+
</FSCheckoutProvider>
29+
</AppContent>
30+
</AppMain>
31+
);
32+
}

src/components/app-sidebar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ const data = {
3636
},
3737
],
3838
navFooterLoggedIn: [
39-
// {
40-
// title: 'Billing & Payments',
41-
// url: '/billing',
42-
// icon: IconReceipt,
43-
// },
39+
{
40+
title: 'Billing & Payments',
41+
url: '/billing',
42+
icon: IconReceipt,
43+
},
4444
{
4545
title: 'Credits & Topups',
4646
url: '/credits',

0 commit comments

Comments
 (0)