Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/components/navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
}

beforeNavigate(() => (showAccountMenu = false));

onMount(() => {
if (resolvedProfile.showExtendedAccountsMenu) {
fetchImagineCredits(currentOrg);
Expand Down Expand Up @@ -300,7 +301,7 @@
direction="row"
justifyContent="space-between"
alignItems="center"
>{credits} Credits left
>{credits} Credit(s) left
</Layout.Stack>
<svelte:fragment slot="more">
<ProgressBar
Expand Down
2 changes: 1 addition & 1 deletion src/lib/studio/studio.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
onUpgrade: async () => {
const organization = get(organizationStore).$id;
goto(
await goto(
resolve('/(console)/organization-[organization]/change-plan', {
organization: organization
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { afterNavigate, goto, invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { afterNavigate, beforeNavigate, goto, invalidate } from '$app/navigation';
import { base, resolve } from '$app/paths';
import { page } from '$app/state';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { PlanComparisonBox, PlanSelection, SelectPaymentMethod } from '$lib/components/billing';
Expand Down Expand Up @@ -36,16 +36,18 @@
import type { OrganizationUsage } from '$lib/sdk/billing';
import type { Models } from '@appwrite.io/console';
import { toLocaleDate } from '$lib/helpers/date';
import { resolvedProfile } from '$lib/profiles/index.svelte';
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
import { isFreePlan, isPaidPlan } from '$lib/helpers/billing.js';
import { studioRef } from '$lib/studio/studio-widget';
import { hash } from '$lib/helpers/string';

export let data;

let selectedCoupon: Partial<Coupon> = null;

let selectedPlan: BillingPlan = data.plan as BillingPlan;

let previousPage: string = base;
let previousPage: string = resolve('/');
let showExitModal = false;
let formComponent: Form;
let usageLimitsComponent:
Expand Down Expand Up @@ -116,6 +118,18 @@
}
});

async function compatNavigation(url: string) {
if (resolvedProfile.id === ProfileMode.STUDIO) {
if (window) {
window.location.href = url;
} else {
await goto(url);
}
} else {
await goto(url);
}
}

async function loadPaymentMethods() {
paymentMethods = await sdk.forConsole.billing.listPaymentMethods();
return paymentMethods;
Expand Down Expand Up @@ -178,7 +192,7 @@

await Promise.all([trackDowngradeFeedback(), invalidate(Dependencies.ORGANIZATION)]);

await goto(previousPage);
await compatNavigation(previousPage);

addNotification({
type: 'success',
Expand All @@ -204,7 +218,8 @@
await invalidate(Dependencies.ACCOUNT);
await invalidate(Dependencies.ORGANIZATION);

await goto(previousPage);
await compatNavigation(previousPage);

addNotification({
type: 'success',
message: 'Your organization has been upgraded'
Expand Down Expand Up @@ -275,7 +290,8 @@
await invalidate(Dependencies.ACCOUNT);
await invalidate(Dependencies.ORGANIZATION);

await goto(previousPage);
await compatNavigation(previousPage);

addNotification({
type: 'success',
message: 'Your organization has been upgraded'
Expand Down
Loading