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

View File

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