feat(#59): Enable showing subscriptions and transactions

This commit is contained in:
Josh Creek
2024-11-01 20:12:08 +00:00
parent 3189d8932b
commit f1f2fe99d7
3 changed files with 143 additions and 38 deletions
+14 -6
View File
@@ -1,5 +1,6 @@
import { fail, redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types';
import { getUserSubscriptions, getUserTransactions } from '$lib/utils/supabase/admin';
export const load: PageServerLoad = async ({ locals: { supabase, safeGetSession } }) => {
const { session } = await safeGetSession();
@@ -14,7 +15,11 @@ export const load: PageServerLoad = async ({ locals: { supabase, safeGetSession
.eq('id', session.user.id)
.single();
return { session, user };
const subscriptions = await getUserSubscriptions(session.user.id);
const transactions = await getUserTransactions(session.user.id);
return { session, user, subscriptions, transactions };
};
export const actions: Actions = {
@@ -27,20 +32,23 @@ export const actions: Actions = {
if (!session) {
return fail(401, { name });
}
const { error } = await supabase.from('users').update({
name: name,
}).eq('id', session?.user.id);
const { error } = await supabase
.from('users')
.update({
name: name
})
.eq('id', session?.user.id);
console.error(error);
if (error) {
return fail(500, {
name,
name
});
}
return {
name,
name
};
},
signout: async ({ locals: { supabase, safeGetSession } }) => {