diff --git a/src/lib/layout/activity.svelte b/src/lib/layout/activity.svelte index 05358bc95..ab250ce96 100644 --- a/src/lib/layout/activity.svelte +++ b/src/lib/layout/activity.svelte @@ -18,12 +18,13 @@ import { Container, ContainerHeader } from '$lib/layout'; import { hoursToDays, toLocaleDateTime } from '$lib/helpers/date'; import type { Models } from '@appwrite.io/console'; + import type { PlanServices } from '$lib/stores/billing'; export let logs: Models.LogList; export let offset = 0; export let limit = 0; - export let service: string = null; + export let service: PlanServices = null; diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 5dfb2fbdb..101ca6020 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -165,10 +165,12 @@ export type AddressesList = { }; export type AdditionalResource = { - unit: string; currency: string; + invoiceDesc: string; price: number; + unit: string; value: number; + multiplier?: number; }; export type Plan = { @@ -188,12 +190,14 @@ export type Plan = { executions: number; realtime: number; logs: number; - bandwidthAddon: AdditionalResource | null; - storageAddon: AdditionalResource | null; - memberAddon: AdditionalResource | null; - usersAddon: AdditionalResource | null; - executionsAddon: AdditionalResource | null; - realtimeAddon: AdditionalResource | null; + addons: { + bandwidth: AdditionalResource; + executions: AdditionalResource; + member: AdditionalResource; + realtime: AdditionalResource; + storage: AdditionalResource; + users: AdditionalResource; + }; }; export type PlansInfo = { diff --git a/src/routes/console/organization-[organization]/createMember.svelte b/src/routes/console/organization-[organization]/createMember.svelte index 0202e43ef..f60d3dd60 100644 --- a/src/routes/console/organization-[organization]/createMember.svelte +++ b/src/routes/console/organization-[organization]/createMember.svelte @@ -60,7 +60,7 @@ You can add unlimited organization members on the {plan.name} plan at no cost. {:else if $organization?.billingPlan === 'tier-1'} You can add unlimited organization members on the {plan.name} plan for - ${plan.memberAddon.price} each per billing period. + ${plan.addons.member.price} each per billing period. {/if} {/if} diff --git a/src/routes/console/project-[project]/store.ts b/src/routes/console/project-[project]/store.ts index 4413c76dd..2e48d7bb1 100644 --- a/src/routes/console/project-[project]/store.ts +++ b/src/routes/console/project-[project]/store.ts @@ -3,7 +3,11 @@ import type { Models } from '@appwrite.io/console'; import type { BarSeriesOption } from 'echarts/charts'; import { derived, writable } from 'svelte/store'; -export const project = derived(page, ($page) => $page.data.project as Models.Project); +// TODO: remove region type once the SDK is updated +export const project = derived( + page, + ($page) => $page.data.project as Models.Project & { region?: string } +); export const onboarding = derived( project, ($project) => $project?.platforms?.length === 0 && $project?.keys?.length === 0 diff --git a/src/routes/console/wizard/cloudOrganization/step3.svelte b/src/routes/console/wizard/cloudOrganization/step3.svelte index 79e31b35d..b034b61f2 100644 --- a/src/routes/console/wizard/cloudOrganization/step3.svelte +++ b/src/routes/console/wizard/cloudOrganization/step3.svelte @@ -14,8 +14,6 @@ import { plansInfo } from '$lib/stores/billing'; import { createOrganization } from './store'; - const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan); - let email: string; function addCollaborator() { @@ -30,6 +28,10 @@ (collaborator) => collaborator !== email ); } + + const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan); + + $: console.log(plan); @@ -45,8 +47,8 @@ added will receive an email invite to your organization on completion. {:else if $createOrganization.billingPlan === 'tier-1'} You can add unlimited organization members on the {plan.name} plan for - ${plan.memberAddon.price} each per month. Each member added will receive an email - invite to your organization on completion. + ${plan.addons.member.price} each per month. Each member added will receive an + email invite to your organization on completion. {/if} diff --git a/src/routes/console/wizard/cloudOrganization/step4.svelte b/src/routes/console/wizard/cloudOrganization/step4.svelte index 6c973f4fa..f129b0ccb 100644 --- a/src/routes/console/wizard/cloudOrganization/step4.svelte +++ b/src/routes/console/wizard/cloudOrganization/step4.svelte @@ -8,7 +8,7 @@ import { createOrganization } from './store'; const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan); - const collaboratorPrice = plan?.memberAddon?.price ?? 0; + const collaboratorPrice = plan?.addons.member?.price ?? 0; const collaboratorsNumber = $createOrganization?.collaborators?.length ?? 0; const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber; const today = new Date(); diff --git a/src/routes/console/wizard/cloudOrganization/usageRates.svelte b/src/routes/console/wizard/cloudOrganization/usageRates.svelte index bfe515f3d..fb0be160b 100644 --- a/src/routes/console/wizard/cloudOrganization/usageRates.svelte +++ b/src/routes/console/wizard/cloudOrganization/usageRates.svelte @@ -81,7 +81,7 @@ {#if !isFree} - ${plan.memberAddon.price}/{usage?.unit} + ${plan.addons.member.price}/{usage?.unit} {/if} diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte index ee0f6df62..e0d642876 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step3.svelte @@ -45,8 +45,8 @@ added will receive an email invite to your organization on completion. {:else if $changeOrganizationTier.billingPlan === 'tier-1'} You can add unlimited organization members on the {plan.name} plan for - ${plan.memberAddon.price} each per month. Each member added will receive an email - invite to your organization on completion. + ${plan.addons.member.price} each per month. Each member added will receive an + email invite to your organization on completion. {/if} diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step5.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step5.svelte index 6f262ed51..822728aac 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/step5.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step5.svelte @@ -10,7 +10,7 @@ import { changeOrganizationFinalAction, changeOrganizationTier, isUpgrade } from './store'; const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan); - const collaboratorPrice = plan?.memberAddon?.price ?? 0; + const collaboratorPrice = plan?.addons.member?.price ?? 0; const collaboratorsNumber = $changeOrganizationTier?.collaborators?.length ?? 0; const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber; const today = new Date();