Skip to content

Commit afcae38

Browse files
Merge pull request #756 from appwrite/chore-format-prices
chore: format prices
2 parents f5d0192 + 9506f71 commit afcae38

File tree

18 files changed

+169
-389
lines changed

18 files changed

+169
-389
lines changed

src/lib/components/billing/couponInput.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { Button, FormList, InputText } from '$lib/elements/forms';
3+
import { formatCurrency } from '$lib/helpers/numbers';
34
import type { Coupon } from '$lib/sdk/billing';
45
import { sdk } from '$lib/stores/sdk';
56
import { createEventDispatcher } from 'svelte';
@@ -64,7 +65,9 @@
6465
<span class="icon-tag u-color-text-success" />
6566
<slot data={couponData}>
6667
<span>
67-
{couponData.code.toUpperCase()} applied (-${couponData.credits})
68+
{couponData.code.toUpperCase()} applied (-{formatCurrency(
69+
couponData.credits
70+
)})
6871
</span>
6972
</slot>
7073
</div>

src/lib/components/cardGrid.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
export let danger = false;
55
export let hideOverflow = false;
6+
export let hideFooter = false;
67
</script>
78

89
<Card {danger}>
@@ -14,7 +15,7 @@
1415
<slot name="aside" />
1516
</div>
1617
</div>
17-
{#if $$slots.actions}
18+
{#if $$slots.actions && !hideFooter}
1819
<div class="common-section card-separator u-flex u-main-end">
1920
<slot name="actions" />
2021
</div>

src/lib/constants.ts

Lines changed: 0 additions & 339 deletions
Original file line numberDiff line numberDiff line change
@@ -279,345 +279,6 @@ export const eventServices: Array<EventService> = [
279279
}
280280
];
281281

282-
export const usageRates = {
283-
'tier-0': [
284-
{
285-
id: 'members',
286-
resource: 'Organization members',
287-
amount: 1,
288-
unit: '',
289-
rate: '$20/member'
290-
},
291-
{ id: 'bandwith', resource: 'Bandwidth', amount: 10, unit: 'GB', rate: '$0.04/GB' },
292-
{ id: 'storage', resource: 'Storage', amount: 2, unit: 'GB', rate: '$0.025/GB' },
293-
{
294-
id: 'executions',
295-
resource: 'Function executions',
296-
amount: 750000,
297-
unit: 'executions',
298-
rate: '$2/1M executions'
299-
},
300-
{
301-
id: 'users',
302-
resource: 'Active users',
303-
amount: 200000,
304-
unit: 'AU',
305-
rate: '$0.0012/user'
306-
},
307-
{
308-
id: 'connections',
309-
resource: 'Concurrent connections',
310-
amount: 750,
311-
unit: 'connections',
312-
rate: '$5/1K connections'
313-
}
314-
],
315-
'tier-1': [
316-
{
317-
id: 'members',
318-
resource: 'Organization members',
319-
amount: 'Unlimited',
320-
unit: '',
321-
rate: '$20/member'
322-
},
323-
{ id: 'bandwith', resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
324-
{ id: 'storage', resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
325-
{
326-
id: 'executions',
327-
resource: 'Function executions',
328-
amount: 3500000,
329-
unit: 'executions',
330-
rate: '$2/1M executions'
331-
},
332-
{
333-
id: 'users',
334-
resource: 'Active users',
335-
amount: 200000,
336-
unit: 'AU',
337-
rate: '$0.0012/user'
338-
},
339-
{
340-
id: 'connections',
341-
resource: 'Concurrent connections',
342-
amount: 750,
343-
unit: 'connections',
344-
rate: '$5/1K connections'
345-
}
346-
],
347-
'tier-2': [
348-
{
349-
id: 'members',
350-
resource: 'Organization members',
351-
amount: 'Unlimited',
352-
unit: '',
353-
rate: '$20/member'
354-
},
355-
{ id: 'bandwith', resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
356-
{ id: 'storage', resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
357-
{
358-
id: 'executions',
359-
resource: 'Function executions',
360-
amount: 3500000,
361-
unit: 'executions',
362-
rate: '$2/1M executions'
363-
},
364-
{
365-
id: 'users',
366-
resource: 'Active users',
367-
amount: 200000,
368-
unit: 'AU',
369-
rate: '$0.0012/user'
370-
},
371-
{
372-
id: 'connections',
373-
resource: 'Concurrent connections',
374-
amount: 750,
375-
unit: 'connections',
376-
rate: '$5/1K connections'
377-
}
378-
]
379-
};
380-
381-
//resources: bandwidth, buckets, file size limit, functions, executions, users,teams,logs, members, platforms, webhooks, databases, connections, messages
382-
export const limitRates = {
383-
'tier-0': [
384-
{
385-
id: 'bandwith',
386-
amount: 10,
387-
unit: 'GB'
388-
},
389-
{
390-
id: 'buckets',
391-
amount: 3,
392-
unit: ''
393-
},
394-
{
395-
id: 'file-size-limit',
396-
amount: 1,
397-
unit: 'MB'
398-
},
399-
{
400-
id: 'storage',
401-
amount: 5,
402-
unit: 'GB'
403-
},
404-
{
405-
id: 'functions',
406-
amount: 1,
407-
unit: ''
408-
},
409-
{
410-
id: 'executions',
411-
amount: 750000,
412-
unit: 'executions'
413-
},
414-
{
415-
id: 'users',
416-
amount: 200000,
417-
unit: 'AU'
418-
},
419-
420-
{
421-
id: 'teams',
422-
amount: 1,
423-
unit: ''
424-
},
425-
426-
{
427-
id: 'logs',
428-
amount: 1,
429-
unit: ''
430-
},
431-
432-
{
433-
id: 'members',
434-
amount: 1,
435-
unit: ''
436-
},
437-
{
438-
id: 'platforms',
439-
amount: 1,
440-
unit: ''
441-
},
442-
{
443-
id: 'webhooks',
444-
amount: 1,
445-
unit: ''
446-
},
447-
{
448-
id: 'databases',
449-
amount: 1,
450-
unit: ''
451-
},
452-
{
453-
id: 'connections',
454-
amount: 1,
455-
unit: ''
456-
},
457-
{
458-
id: 'messages',
459-
amount: 1,
460-
unit: ''
461-
}
462-
],
463-
'tier-1': [
464-
{
465-
id: 'bandwith',
466-
amount: 10,
467-
unit: 'GB'
468-
},
469-
{
470-
id: 'buckets',
471-
amount: 1,
472-
unit: ''
473-
},
474-
{
475-
id: 'file-size-limit',
476-
amount: 5,
477-
unit: 'MB'
478-
},
479-
{
480-
id: 'storage',
481-
amount: 5,
482-
unit: 'GB'
483-
},
484-
{
485-
id: 'functions',
486-
amount: 1,
487-
unit: ''
488-
},
489-
{
490-
id: 'executions',
491-
amount: 750000,
492-
unit: 'executions'
493-
},
494-
{
495-
id: 'users',
496-
amount: 200000,
497-
unit: 'AU'
498-
},
499-
500-
{
501-
id: 'teams',
502-
amount: 1,
503-
unit: ''
504-
},
505-
{
506-
id: 'logs',
507-
amount: 1,
508-
unit: ''
509-
},
510-
{
511-
id: 'members',
512-
amount: 1,
513-
unit: ''
514-
},
515-
{
516-
id: 'platforms',
517-
amount: 1,
518-
unit: ''
519-
},
520-
{
521-
id: 'webhooks',
522-
amount: 1,
523-
unit: ''
524-
},
525-
{
526-
id: 'databases',
527-
amount: 1,
528-
unit: ''
529-
},
530-
{
531-
id: 'connections',
532-
amount: 1,
533-
unit: ''
534-
},
535-
{
536-
id: 'messages',
537-
amount: 1,
538-
unit: ''
539-
}
540-
],
541-
'tier-2': [
542-
{
543-
id: 'bandwith',
544-
amount: 10,
545-
unit: 'GB'
546-
},
547-
{
548-
id: 'buckets',
549-
amount: 1,
550-
unit: ''
551-
},
552-
{
553-
id: 'file-size-limit',
554-
amount: 5,
555-
unit: 'MB'
556-
},
557-
{
558-
id: 'storage',
559-
amount: 5,
560-
unit: 'GB'
561-
},
562-
{
563-
id: 'functions',
564-
amount: 1,
565-
unit: ''
566-
},
567-
{
568-
id: 'executions',
569-
amount: 750000,
570-
unit: 'executions'
571-
},
572-
{
573-
id: 'users',
574-
amount: 200000,
575-
unit: 'AU'
576-
},
577-
578-
{
579-
id: 'teams',
580-
amount: 1,
581-
unit: ''
582-
},
583-
{
584-
id: 'logs',
585-
amount: 1,
586-
unit: ''
587-
},
588-
{
589-
id: 'members',
590-
amount: 1,
591-
unit: ''
592-
},
593-
{
594-
id: 'platforms',
595-
amount: 1,
596-
unit: ''
597-
},
598-
{
599-
id: 'webhooks',
600-
amount: 1,
601-
unit: ''
602-
},
603-
{
604-
id: 'databases',
605-
amount: 1,
606-
unit: ''
607-
},
608-
{
609-
id: 'connections',
610-
amount: 1,
611-
unit: ''
612-
},
613-
{
614-
id: 'messages',
615-
amount: 1,
616-
unit: ''
617-
}
618-
]
619-
};
620-
621282
export enum BillingPlan {
622283
STARTER = 'tier-0',
623284
PRO = 'tier-1',

src/lib/helpers/numbers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ export function formatNumberWithCommas(number: number): string {
2020
const formatter = new Intl.NumberFormat('en');
2121
return formatter.format(number);
2222
}
23+
24+
export function formatCurrency(number: number, locale = 'en-US', currency = 'USD'): string {
25+
if (isNaN(number)) return String(number);
26+
const formatter = new Intl.NumberFormat(locale, {
27+
style: 'currency',
28+
currency
29+
});
30+
return formatter.format(number);
31+
}

0 commit comments

Comments
 (0)