mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: trial changes
This commit is contained in:
1 parent
57dc36c751
commit
92c7f43888
12 files changed
+42
-23
No files matched your search
@@ -10,7 +10,7 @@ import type {
|
||||
PlansMap,
|
||||
PaymentMethodData
|
||||
} from '$lib/sdk/billing';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { TRIAL_PERIOD_OVERRIDE, isCloud } from '$lib/system';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { headerAlert } from './headerAlert';
|
||||
@@ -165,6 +165,7 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num
|
||||
}
|
||||
|
||||
export function calculateTrialDay(org: Organization) {
|
||||
if (TRIAL_PERIOD_OVERRIDE) return;
|
||||
if (org?.billingPlan === BillingPlan.STARTER) return false;
|
||||
const endDate = new Date(org?.billingStartDate);
|
||||
const today = new Date();
|
||||
|
||||
@@ -24,3 +24,4 @@ export const isCloud = MODE === Mode.CLOUD;
|
||||
export const isSelfHosted = MODE !== Mode.CLOUD;
|
||||
export const hasStripePublicKey = !!VARS.STRIPE_PUBLIC_KEY;
|
||||
export const GRACE_PERIOD_OVERRIDE = false;
|
||||
export const TRIAL_PERIOD_OVERRIDE = true;
|
||||
@@ -13,7 +13,7 @@
|
||||
import CreateOrganization from '../../createOrganization.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageData } from './$types';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { TRIAL_PERIOD_OVERRIDE, isCloud } from '$lib/system';
|
||||
import { Pill } from '$lib/elements';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Organization } from '$lib/stores/organization';
|
||||
@@ -82,7 +82,7 @@
|
||||
<Pill>FREE</Pill>
|
||||
</div>
|
||||
{/if}
|
||||
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.STARTER}
|
||||
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.STARTER && !TRIAL_PERIOD_OVERRIDE}
|
||||
<div
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
|
||||
let currentInvoice: Invoice;
|
||||
const today = new Date();
|
||||
@@ -29,7 +30,7 @@
|
||||
|
||||
$: currentPlan = $plansInfo?.get($organization?.billingPlan);
|
||||
$: extraUsage = currentInvoice?.amount - currentPlan?.price;
|
||||
$: isTrial = new Date($organization?.billingStartDate).getTime() - today.getTime() > 0;
|
||||
$: isTrial = (new Date($organization?.billingStartDate).getTime() - today.getTime() > 0 ) && !TRIAL_PERIOD_OVERRIDE;
|
||||
</script>
|
||||
|
||||
{#if $organization}
|
||||
@@ -53,7 +54,7 @@
|
||||
<h6 class="body-text-1 u-bold u-trim-1">
|
||||
{tierToPlan($organization?.billingPlan)?.name} plan
|
||||
</h6>
|
||||
{#if $organization?.billingPlan !== BillingPlan.STARTER && isTrial}
|
||||
{#if $organization?.billingPlan !== BillingPlan.STARTER && isTrial && }
|
||||
<Pill>TRIAL</Pill>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
organizationList
|
||||
} from '$lib/stores/organization';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
|
||||
import { GRACE_PERIOD_OVERRIDE, TRIAL_PERIOD_OVERRIDE, isCloud } from '$lib/system';
|
||||
import CreateOrganizationCloud from '../createOrganizationCloud.svelte';
|
||||
|
||||
let areMembersLimited: boolean;
|
||||
@@ -94,7 +94,7 @@
|
||||
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER}
|
||||
<Pill>FREE</Pill>
|
||||
{/if}
|
||||
{#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.STARTER}
|
||||
{#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.STARTER && !TRIAL_PERIOD_OVERRIDE}
|
||||
<div
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import { plansInfo } from '$lib/stores/billing';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
import { createOrganization, createOrganizationFinalAction } from './store';
|
||||
|
||||
const plan = $plansInfo?.get($createOrganization.billingPlan);
|
||||
@@ -53,7 +54,9 @@
|
||||
<WizardStep beforeSubmit={handleBefore}>
|
||||
<svelte:fragment slot="title">Confirm your details</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Confirm the details of your new organization and start your free trial.
|
||||
Confirm the details of your new organization{TRIAL_PERIOD_OVERRIDE
|
||||
? '.'
|
||||
: ' and start your free trial.'}
|
||||
</svelte:fragment>
|
||||
|
||||
<p class="body-text-1 u-bold">Organization name</p>
|
||||
@@ -123,9 +126,9 @@
|
||||
{#if $createOrganization.billingPlan !== BillingPlan.STARTER}
|
||||
<p class="text u-margin-block-start-16">
|
||||
This amount, and any additional usage fees, will be charged on a recurring 30-day
|
||||
billing cycle after your trial period ends on <b
|
||||
>{toLocaleDate(billingPayDate.toString())}</b
|
||||
>.
|
||||
billing cycle{TRIAL_PERIOD_OVERRIDE
|
||||
? '.'
|
||||
: ` after your trial period ends on ${toLocaleDate(billingPayDate.toString())}`}.
|
||||
</p>
|
||||
{/if}
|
||||
</Box>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { plansInfo, tierFree, tierPro, tierScale } from '$lib/stores/billing';
|
||||
import { organizationList, type Organization } from '$lib/stores/organization';
|
||||
import { updateStepStatus } from '$lib/stores/wizard';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
import { createOrganization, createOrgSteps } from './store';
|
||||
|
||||
let showCustomId = false;
|
||||
@@ -108,7 +109,9 @@
|
||||
{tierPro.description}
|
||||
</p>
|
||||
</div>
|
||||
<Pill>14 DAY FREE TRIAL</Pill>
|
||||
{#if !TRIAL_PERIOD_OVERRIDE}
|
||||
<Pill>14 DAY FREE TRIAL</Pill>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</LabelCard>
|
||||
</li>
|
||||
@@ -131,7 +134,6 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class:u-opacity-50={disabled}>
|
||||
<!-- <Pill>14 DAY FREE TRIAL</Pill> -->
|
||||
<Pill disabled>COMING SOON</Pill>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { showUsageRatesModal } from '$lib/stores/billing';
|
||||
import { PaymentBoxes } from '$lib/components/billing';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
|
||||
const today = new Date();
|
||||
const billingPayDate = new Date(today.getTime() + 44 * 24 * 60 * 60 * 1000);
|
||||
@@ -74,9 +75,9 @@
|
||||
<WizardStep beforeSubmit={handleSubmit}>
|
||||
<svelte:fragment slot="title">Payment details</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Add a payment method to your organization. You will not be charged until your trial ends on <b
|
||||
>{toLocaleDate(billingPayDate.toString())}</b
|
||||
>.
|
||||
Add a payment method to your organization. {#if !TRIAL_PERIOD_OVERRIDE}You will not be
|
||||
charged until your trial ends on <b>{toLocaleDate(billingPayDate.toString())}</b>.
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
||||
<FormList class="u-margin-block-start-8">
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import type { Tier } from '$lib/stores/billing';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const createOrgSteps = writable<WizardStepsType>(new Map());
|
||||
export const createOrganizationFinalAction = writable<string>('Start trial');
|
||||
export const createOrganizationFinalAction = writable<string>(
|
||||
TRIAL_PERIOD_OVERRIDE ? 'Create' : 'Start trial'
|
||||
);
|
||||
|
||||
export const createOrganization = writable<{
|
||||
id?: string;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { formatCurrency } from '$lib/helpers/numbers';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
|
||||
let usage: OrganizationUsage = null;
|
||||
let members: Models.MembershipList = null;
|
||||
@@ -161,7 +162,7 @@
|
||||
<div class:u-opacity-50={disabled}>
|
||||
{#if $organization.billingPlan === BillingPlan.PRO}
|
||||
<Pill disabled>CURRENT PLAN</Pill>
|
||||
{:else}
|
||||
{:else if !TRIAL_PERIOD_OVERRIDE}
|
||||
<Pill>14 DAY FREE TRIAL</Pill>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
feedbackDowngradeOptions,
|
||||
isUpgrade
|
||||
} from './store';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
|
||||
const plan = $plansInfo.get($changeOrganizationTier.billingPlan);
|
||||
const collaboratorPrice = plan?.addons.member?.price ?? 0;
|
||||
@@ -77,7 +78,9 @@
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">Confirm your details</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Confirm the details of your new organization and start your free trial.
|
||||
Confirm the details of your new organization{TRIAL_PERIOD_OVERRIDE
|
||||
? '.'
|
||||
: ' and start your free trial.'}
|
||||
</svelte:fragment>
|
||||
|
||||
<p class="body-text-1 u-bold">Organization name</p>
|
||||
@@ -144,9 +147,9 @@
|
||||
|
||||
<p class="text u-margin-block-start-16">
|
||||
This amount, and any additional usage fees, will be charged on a recurring 30-day
|
||||
billing cycle after your trial period ends on <b
|
||||
>{toLocaleDate(billingPayDate.toString())}</b
|
||||
>.
|
||||
billing cycle{TRIAL_PERIOD_OVERRIDE
|
||||
? '.'
|
||||
: ` after your trial period ends on ${toLocaleDate(billingPayDate.toString())}`}.
|
||||
</p>
|
||||
</Box>
|
||||
</WizardStep>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import type { Tier } from '$lib/stores/billing';
|
||||
import { TRIAL_PERIOD_OVERRIDE } from '$lib/system';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const changeTierSteps = writable<WizardStepsType>(new Map());
|
||||
export const isUpgrade = writable<boolean>(false);
|
||||
export const changeOrganizationFinalAction = writable<string>('Start trial');
|
||||
export const changeOrganizationFinalAction = writable<string>(
|
||||
TRIAL_PERIOD_OVERRIDE ? 'Create' : 'Start trial'
|
||||
);
|
||||
|
||||
export const changeOrganizationTier = writable<{
|
||||
billingPlan: Tier;
|
||||
|
||||
Reference in new issue
Block a user