Merge pull request #677 from appwrite/fix-upgrade-flow

fix: upgrade flow
This commit is contained in:
Eldad A. Fux authored and GitHub committed 2023-12-21 13:26:09 +01:00
commit 207b68b0a3
7 files changed
+22 -8

No files matched your search

+2 -2
View File
@@ -158,7 +158,7 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num
export function calculateTrialDay(org: Organization) {
if (org?.billingPlan === 'tier-0') return false;
const endDate = new Date(org?.billingTrialEndDate);
const endDate = new Date(org?.billingStartDate);
const today = new Date();
const days = diffDays(today, endDate);
daysLeftInTrial.set(days);
@@ -176,7 +176,7 @@ export function checkForTrialEnding(org: Organization) {
tierToPlan(org.billingPlan).name
} plan.</b>
You will be billed on a recurring 30-day cycle after your trial period ends on <b>${toLocaleDate(
org.billingTrialEndDate
org.billingStartDate
)}</b>`
});
localStorage.setItem('trialEndingNotification', 'true');
+1 -1
View File
@@ -14,7 +14,7 @@ export type Organization = Models.Team<Record<string, unknown>> & {
billingCurrentInvoiceDate: string;
billingNextInvoiceDate: string;
billingTrialStartDate?: string;
billingTrialEndDate?: string;
billingStartDate?: string;
billingTrialDays?: number;
billingAddressId?: string;
amount: number;
@@ -86,7 +86,7 @@
class="u-flex u-cross-center"
use:tooltip={{
content: `Your trial ends on ${toLocaleDate(
organization.billingTrialEndDate
organization.billingStartDate
)}. ${$daysLeftInTrial} days remaining.`
}}>
<Pill>FREE TRIAL</Pill>
@@ -27,7 +27,7 @@
$: currentPlan = $plansInfo.plans.find((p) => p.$id === $organization?.billingPlan);
$: extraUsage = currentInvoice?.amount - currentPlan?.price;
$: isTrial = new Date($organization?.billingTrialEndDate).getTime() - today.getTime() > 0;
$: isTrial = new Date($organization?.billingStartDate).getTime() - today.getTime() > 0;
</script>
{#if $organization}
@@ -97,7 +97,7 @@
class="u-flex u-cross-center"
use:tooltip={{
content: `Your trial ends on ${toLocaleDate(
$organization.billingTrialEndDate
$organization.billingStartDate
)}. ${$daysLeftInTrial} days remaining.`
}}>
<Pill>FREE TRIAL</Pill>
@@ -64,10 +64,10 @@
$changeOrganizationTier.limitOverflow.members > 0
) {
$changeOrganizationTier.isOverLimit = true;
$changeTierSteps = updateStepStatus($changeTierSteps, 4, false);
$changeTierSteps = updateStepStatus($changeTierSteps, 5, false);
} else {
$changeOrganizationTier.isOverLimit = false;
$changeTierSteps = updateStepStatus($changeTierSteps, 4, true);
$changeTierSteps = updateStepStatus($changeTierSteps, 5, true);
}
}
@@ -12,12 +12,26 @@
} from '$lib/elements/table';
import { WizardStep } from '$lib/layout';
import { plansInfo } from '$lib/stores/billing';
import { onMount } from 'svelte';
import { changeOrganizationTier } from './store';
import { sdk } from '$lib/stores/sdk';
import { user } from '$lib/stores/user';
const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
let email: string;
onMount(async () => {
const members = await sdk.forConsole.teams.listMemberships($changeOrganizationTier.id);
if (members.total) {
$changeOrganizationTier.collaborators = members.memberships
.map((m) => {
if (m.userEmail !== $user.email) return m.userEmail;
})
.filter(Boolean);
}
});
function addCollaborator() {
if (!email) return;
if ($changeOrganizationTier.collaborators.includes(email)) return;