temp wip, downgrade & upgrade w. credit not implemented

This commit is contained in:
marko-kraemer 2025-04-26 20:54:41 +01:00
parent 28da425ce8
commit 09c4099ca5
2 changed files with 15 additions and 5 deletions

View File

@ -101,6 +101,8 @@ function LoginContent() {
const handleSignIn = async (prevState: any, formData: FormData) => {
if (returnUrl) {
formData.append("returnUrl", returnUrl);
} else {
formData.append("returnUrl", "/dashboard");
}
return signIn(prevState, formData);
};
@ -166,9 +168,10 @@ function LoginContent() {
const resetRegistrationSuccess = () => {
setRegistrationSuccess(false);
// Remove message from URL
// Remove message from URL and set mode to signin
const params = new URLSearchParams(window.location.search);
params.delete('message');
params.set('mode', 'signin');
const newUrl =
window.location.pathname +

View File

@ -84,7 +84,7 @@ export async function getAccountSubscription(accountId: string) {
const supabaseClient = await createClient();
// Get account subscription data
const { data: subscriptionData, error: subscriptionError } = await supabaseClient
let { data: subscriptionData, error: subscriptionError } = await supabaseClient
.schema('basejump')
.from('billing_subscriptions')
.select('*')
@ -94,9 +94,16 @@ export async function getAccountSubscription(accountId: string) {
.order('created', { ascending: false })
.single();
if (subscriptionError) {
console.error("Error fetching subscription data:", subscriptionError);
return { message: subscriptionError.message };
// If no subscription found or error, return default FREE tier
if (subscriptionError || !subscriptionData) {
console.log("No active subscription found, defaulting to FREE tier");
subscriptionData = {
plan_id: 'free',
status: 'active',
price_id: null,
customer_id: null,
subscription_id: null
};
}
console.log("Subscription data:", subscriptionData);