Handle sub in dashboard

This commit is contained in:
Michael
2021-06-25 18:19:35 +02:00
parent c8fd50ab27
commit 4068f18852
6 changed files with 199 additions and 116 deletions

45
utils/priceList.js Normal file
View File

@@ -0,0 +1,45 @@
// You can store your price IDs from Stripe here
const Prices = {
personal: {
monthly: {
id: "price_1J5q2yDMjD0UnVmMXzEWYDnl",
desc: "Personal plan (monthly)",
},
anually: {
id: "price_1J5q45DMjD0UnVmMQxXHKGAv",
desc: "Personal plan (anually)",
},
},
team: {
monthly: {
id: "price_1J5q3GDMjD0UnVmMlHc5Eedq",
desc: "Team plan (monthly)",
},
anually: {
id: "price_1J5q8zDMjD0UnVmMqsngM91X",
desc: "Team plan (anually)",
},
},
pro: {
monthly: {
id: "price_1J5q3TDMjD0UnVmMJKX3nkDq",
desc: "Pro plan (monthly)",
},
anually: {
id: "price_1J5q9VDMjD0UnVmMIQtVDSZ9",
desc: "Pro plan (anually)",
},
},
};
const PriceIds = {
price_1J5q2yDMjD0UnVmMXzEWYDnl: "Personal plan (monthly)",
price_1J5q45DMjD0UnVmMQxXHKGAv: "Personal plan (anually)",
price_1J5q3GDMjD0UnVmMlHc5Eedq: "Team plan (monthly)",
price_1J5q8zDMjD0UnVmMqsngM91X: "Team plan (anually)",
price_1J5q3TDMjD0UnVmMJKX3nkDq: "Pro plan (monthly)",
price_1J5q9VDMjD0UnVmMIQtVDSZ9: "Pro plan (anually)",
};
export { Prices, PriceIds };

View File

@@ -1,6 +1,16 @@
import { createClient } from '@supabase/supabase-js'
import { createClient } from "@supabase/supabase-js";
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
// Check if a user has a paid plan
export const getSub = async () => {
let { data: subscriptions, error } = await supabase
.from("subscriptions")
.select("paid_user, plan");
if (subscriptions) {
return subscriptions;
}
};