Skip to content

Commit e0890ac

Browse files
committed
chore: updated component
1 parent d3f0aa0 commit e0890ac

File tree

3 files changed

+35
-38
lines changed

3 files changed

+35
-38
lines changed

src/lib/sdk/billing.ts

+1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export type Plan = {
315315
order: number;
316316
bandwidth: number;
317317
storage: number;
318+
imageTransformations: number;
318319
webhooks: number;
319320
users: number;
320321
teams: number;

src/lib/stores/billing.ts

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1+
import { browser } from '$app/environment';
2+
import { goto } from '$app/navigation';
3+
import { base } from '$app/paths';
14
import { page } from '$app/stores';
2-
import { derived, get, writable } from 'svelte/store';
3-
import { sdk } from './sdk';
4-
import { organization, type Organization, type OrganizationError } from './organization';
5+
import { trackEvent } from '$lib/actions/analytics';
6+
import LimitReached from '$lib/components/billing/alerts/limitReached.svelte';
7+
import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte';
8+
import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte';
9+
import newDevUpgradePro from '$lib/components/billing/alerts/newDevUpgradePro.svelte';
10+
import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte';
11+
import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte';
12+
import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants';
13+
import { cachedStore } from '$lib/helpers/cache';
14+
import { sizeToBytes, type Size } from '$lib/helpers/sizeConvertion';
515
import type {
6-
InvoiceList,
716
AddressesList,
17+
Aggregation,
818
Invoice,
19+
InvoiceList,
920
PaymentList,
10-
PlansMap,
1121
PaymentMethodData,
1222
Plan,
13-
Aggregation
23+
PlansMap
1424
} from '$lib/sdk/billing';
1525
import { isCloud } from '$lib/system';
16-
import { cachedStore } from '$lib/helpers/cache';
26+
import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store';
1727
import { Query } from '@appwrite.io/console';
28+
import { derived, get, writable } from 'svelte/store';
1829
import { headerAlert } from './headerAlert';
19-
import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte';
2030
import { addNotification, notifications } from './notifications';
21-
import { goto } from '$app/navigation';
22-
import { base } from '$app/paths';
23-
import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store';
24-
import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte';
25-
import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants';
26-
import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte';
27-
import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte';
28-
import LimitReached from '$lib/components/billing/alerts/limitReached.svelte';
29-
import { trackEvent } from '$lib/actions/analytics';
30-
import newDevUpgradePro from '$lib/components/billing/alerts/newDevUpgradePro.svelte';
31-
import { sizeToBytes, type Size } from '$lib/helpers/sizeConvertion';
32-
import { user } from './user';
33-
import { browser } from '$app/environment';
31+
import { organization, type Organization, type OrganizationError } from './organization';
3432
import { canSeeBilling } from './roles';
33+
import { sdk } from './sdk';
34+
import { user } from './user';
3535

3636
export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'auto-1' | 'cont-1' | 'ent-1';
3737

@@ -130,7 +130,8 @@ export type PlanServices =
130130
| 'users'
131131
| 'usersAddon'
132132
| 'webhooks'
133-
| 'authPhone';
133+
| 'authPhone'
134+
| 'imageTransformations';
134135

135136
export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan?: Plan): number {
136137
if (!isCloud) return 0;

src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte

+11-16
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,17 @@
267267
</p>
268268
<svelte:fragment slot="aside">
269269
{#if data.organizationUsage.imageTransformationsTotal}
270+
{@const current = data.organizationUsage.imageTransformationsTotal}
271+
{@const max = getServiceLimit('imageTransformations', tier, plan)}
270272
<div style:margin-top="-1.5em" style:margin-bottom="-1em">
273+
<ProgressBarBig
274+
currentUnit="Transformations"
275+
currentValue={formatNum(current)}
276+
maxUnit="Transformations"
277+
maxValue={`out of ${formatNum(max)}`}
278+
progressValue={current}
279+
progressMax={max}
280+
showBar={false} />
271281
<BarChart
272282
options={{
273283
yAxis: {
@@ -278,7 +288,7 @@
278288
}}
279289
series={[
280290
{
281-
name: 'Transformations',
291+
name: 'Image Transformations',
282292
data: [
283293
...(data.organizationUsage.imageTransformations ?? []).map(
284294
(e) => [e.date, e.value]
@@ -287,21 +297,6 @@
287297
}
288298
]} />
289299
</div>
290-
291-
<Legend
292-
legendData={[
293-
{
294-
name: 'Transformations',
295-
value: data.organizationUsage.imageTransformationsTotal
296-
}
297-
]} />
298-
299-
{#if projects?.length > 0}
300-
<ProjectBreakdown
301-
{data}
302-
{projects}
303-
databaseOperationMetric={['databasesReads', 'databasesWrites']} />
304-
{/if}
305300
{:else}
306301
<Card isDashed>
307302
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">

0 commit comments

Comments
 (0)