Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upgrade flow #677

Merged
merged 3 commits into from
Dec 21, 2023
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
4 changes: 2 additions & 2 deletions src/lib/stores/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stores/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/console/account/organizations/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down