From 466ffec8fe9ff2629a1811f50251378debf0bc7b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 31 Aug 2021 14:24:10 +0200 Subject: [PATCH] Fix missing column in SQL and fix plan display in the dashboard --- pages/dashboard.tsx | 6 ++++-- setupSupabaseSQL.sql | 1 + utils/AuthContext.js | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index 93dc16c..3aab48f 100644 --- a/pages/dashboard.tsx +++ b/pages/dashboard.tsx @@ -82,12 +82,14 @@ export async function getServerSideProps(context: NextPageContext) { if (user) { const { data: plan } = await supabaseAdmin .from('subscriptions') - .select('plan') + .select('subscription') .eq('id', user.id) .single(); // Check the subscription plan. If it doesnt exist, return null - const subscription = plan?.plan ? await stripe.subscriptions.retrieve(plan.plan) : null; + const subscription = plan?.subscription + ? await stripe.subscriptions.retrieve(plan.subscription) + : null; const { data: profile } = await supabaseAdmin .from('profiles') diff --git a/setupSupabaseSQL.sql b/setupSupabaseSQL.sql index c8f8210..ed19dc6 100644 --- a/setupSupabaseSQL.sql +++ b/setupSupabaseSQL.sql @@ -5,6 +5,7 @@ create table profiles ( username text unique, avatar_url text, website text, + customerId text, primary key (id), unique(username), diff --git a/utils/AuthContext.js b/utils/AuthContext.js index ca9db32..51d8263 100644 --- a/utils/AuthContext.js +++ b/utils/AuthContext.js @@ -14,8 +14,6 @@ export const AuthProvider = ({ children }) => { // Check active sessions and sets the user const session = supabase.auth.session(); - console.log(session); - setUser(session?.user ?? null); setSession(session ?? null); setLoading(false);