mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1397 from appwrite/feat-PRO-1313-support-custom-plan
Feat pro 1313 support custom plan
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
export let billingPlan: Tier;
|
||||
export let anyOrgFree = false;
|
||||
export let isNewOrg = false;
|
||||
export let selfService = true;
|
||||
let classes: string = '';
|
||||
export { classes as class };
|
||||
|
||||
@@ -22,7 +23,7 @@
|
||||
<LabelCard
|
||||
name="plan"
|
||||
bind:group={billingPlan}
|
||||
disabled={anyOrgFree}
|
||||
disabled={anyOrgFree || !selfService}
|
||||
value={BillingPlan.FREE}
|
||||
tooltipShow={anyOrgFree}
|
||||
tooltipText="You are limited to 1 Free organization per account."
|
||||
@@ -49,9 +50,16 @@
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<LabelCard name="plan" bind:group={billingPlan} value={BillingPlan.PRO} padding={1.5}>
|
||||
<svelte:fragment slot="custom">
|
||||
<div class="u-flex u-flex-vertical u-gap-4 u-width-full-line">
|
||||
<LabelCard
|
||||
name="plan"
|
||||
disabled={!selfService}
|
||||
bind:group={billingPlan}
|
||||
value={BillingPlan.PRO}
|
||||
padding={1.5}>
|
||||
<svelte:fragment slot="custom" let:disabled>
|
||||
<div
|
||||
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
|
||||
class:u-opacity-50={disabled}>
|
||||
<h4 class="body-text-2 u-bold">
|
||||
{tierPro.name}
|
||||
{#if $organization?.billingPlan === BillingPlan.PRO && !isNewOrg}
|
||||
|
||||
@@ -467,7 +467,8 @@ export const eventServices: Array<EventService> = [
|
||||
export enum BillingPlan {
|
||||
FREE = 'tier-0',
|
||||
PRO = 'tier-1',
|
||||
SCALE = 'tier-2'
|
||||
SCALE = 'tier-2',
|
||||
CUSTOM = 'cont-1'
|
||||
}
|
||||
|
||||
export const feedbackDowngradeOptions = [
|
||||
|
||||
@@ -277,6 +277,8 @@ export type Plan = {
|
||||
users: AdditionalResource;
|
||||
};
|
||||
trialDays: number;
|
||||
isAvailable: boolean;
|
||||
selfService: boolean;
|
||||
};
|
||||
|
||||
export type PlansInfo = {
|
||||
|
||||
@@ -34,7 +34,7 @@ import { user } from './user';
|
||||
import { browser } from '$app/environment';
|
||||
import { canSeeBilling } from './roles';
|
||||
|
||||
export type Tier = 'tier-0' | 'tier-1' | 'tier-2';
|
||||
export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'cont-1';
|
||||
|
||||
export const roles = [
|
||||
{
|
||||
@@ -77,6 +77,8 @@ export function tierToPlan(tier: Tier) {
|
||||
return tierPro;
|
||||
case BillingPlan.SCALE:
|
||||
return tierScale;
|
||||
case BillingPlan.CUSTOM:
|
||||
return tierCustom;
|
||||
default:
|
||||
return tierFree;
|
||||
}
|
||||
@@ -182,6 +184,11 @@ export const tierScale: TierData = {
|
||||
description: 'For scaling teams and agencies that need dedicated support.'
|
||||
};
|
||||
|
||||
export const tierCustom: TierData = {
|
||||
name: 'Custom',
|
||||
description: 'Team on a custom contract'
|
||||
};
|
||||
|
||||
export const showUsageRatesModal = writable<boolean>(false);
|
||||
|
||||
export function checkForUsageFees(plan: Tier, id: PlanServices) {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
let currentInvoice: Invoice;
|
||||
let extraMembers = 0;
|
||||
let currentPlan;
|
||||
|
||||
const today = new Date();
|
||||
onMount(async () => {
|
||||
const invoices = await sdk.forConsole.billing.listInvoices($organization.$id, [
|
||||
@@ -26,9 +28,10 @@
|
||||
currentInvoice = invoices.invoices[0];
|
||||
const members = await sdk.forConsole.teams.listMemberships($organization.$id, []);
|
||||
extraMembers = members.total > 1 ? members.total - 1 : 0;
|
||||
|
||||
currentPlan = await sdk.forConsole.billing.getPlan($organization?.$id);
|
||||
});
|
||||
|
||||
$: currentPlan = $plansInfo?.get($organization?.billingPlan);
|
||||
$: extraUsage = (currentInvoice?.amount ?? 0) - (currentPlan?.price ?? 0);
|
||||
$: extraAddons = currentInvoice?.usage?.length ?? 0;
|
||||
$: isTrial =
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
|
||||
let feedbackDowngradeReason: string;
|
||||
let feedbackMessage: string;
|
||||
let selfService: boolean;
|
||||
|
||||
onMount(async () => {
|
||||
if ($page.url.searchParams.has('code')) {
|
||||
@@ -99,6 +100,9 @@
|
||||
} else {
|
||||
billingPlan = BillingPlan.PRO;
|
||||
}
|
||||
|
||||
const currentPlan = await sdk.forConsole.billing.getPlan($organization?.$id);
|
||||
selfService = currentPlan.selfService;
|
||||
});
|
||||
|
||||
async function loadPaymentMethods() {
|
||||
@@ -252,8 +256,14 @@
|
||||
For more details on our plans, visit our
|
||||
<Button href="https://appwrite.io/pricing" external link>pricing page</Button>.
|
||||
</p>
|
||||
{#if !selfService}
|
||||
<Alert class="u-position-relative u-margin-block-start-16" type="info"
|
||||
>Your contract is not eligible for manual changes. Please reach out to schedule
|
||||
a call or setup a dialog.</Alert>
|
||||
{/if}
|
||||
<PlanSelection
|
||||
bind:billingPlan
|
||||
bind:selfService
|
||||
anyOrgFree={!!anyOrgFree}
|
||||
class={anyOrgFree && billingPlan !== BillingPlan.FREE
|
||||
? 'u-margin-block-start-16'
|
||||
@@ -323,14 +333,14 @@
|
||||
{/if}
|
||||
</Form>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== billingPlan}
|
||||
{#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== billingPlan && $organization.billingPlan !== BillingPlan.CUSTOM}
|
||||
<EstimatedTotalBox
|
||||
{billingPlan}
|
||||
{collaborators}
|
||||
bind:couponData
|
||||
bind:billingBudget
|
||||
{isDowngrade} />
|
||||
{:else}
|
||||
{:else if $organization.billingPlan !== BillingPlan.CUSTOM}
|
||||
<PlanComparisonBox downgrade={isDowngrade} />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
@@ -341,7 +351,7 @@
|
||||
<Button
|
||||
fullWidthMobile
|
||||
on:click={() => formComponent.triggerSubmit()}
|
||||
disabled={$isSubmitting || isButtonDisabled}>
|
||||
disabled={$isSubmitting || isButtonDisabled || !selfService}>
|
||||
Change plan
|
||||
</Button>
|
||||
</WizardSecondaryFooter>
|
||||
|
||||
Reference in New Issue
Block a user