|
1 | 1 | <script lang="ts">
|
2 |
| - import { BillingPlan } from '$lib/constants'; |
3 | 2 | import { formatCurrency } from '$lib/helpers/numbers';
|
4 |
| - import { plansInfo, tierFree, tierPro, tierScale, type Tier } from '$lib/stores/billing'; |
| 3 | + import { isFreeTier, plansInfo, type Tier } from '$lib/stores/billing'; |
5 | 4 | import { organization } from '$lib/stores/organization';
|
6 | 5 | import { LabelCard } from '..';
|
7 | 6 |
|
|
11 | 10 | export let selfService = true;
|
12 | 11 | let classes: string = '';
|
13 | 12 | export { classes as class };
|
14 |
| -
|
15 |
| - $: freePlan = $plansInfo.get(BillingPlan.FREE); |
16 |
| - $: proPlan = $plansInfo.get(BillingPlan.PRO); |
17 |
| - $: scalePlan = $plansInfo.get(BillingPlan.SCALE); |
18 | 13 | </script>
|
19 | 14 |
|
20 | 15 | {#if billingPlan}
|
21 | 16 | <ul class="u-flex u-flex-vertical u-gap-16 u-margin-block-start-8 {classes}">
|
22 |
| - <li> |
23 |
| - <LabelCard |
24 |
| - name="plan" |
25 |
| - bind:group={billingPlan} |
26 |
| - disabled={anyOrgFree || !selfService} |
27 |
| - value={BillingPlan.FREE} |
28 |
| - tooltipShow={anyOrgFree} |
29 |
| - tooltipText="You are limited to 1 Free organization per account." |
30 |
| - padding={1.5}> |
31 |
| - <svelte:fragment slot="custom" let:disabled> |
32 |
| - <div |
33 |
| - class="u-flex u-flex-vertical u-gap-4 u-width-full-line" |
34 |
| - class:u-opacity-50={disabled}> |
35 |
| - <h4 class="body-text-2 u-bold"> |
36 |
| - {tierFree.name} |
37 |
| - {#if $organization?.billingPlan === BillingPlan.FREE && !isNewOrg} |
38 |
| - <span class="inline-tag">Current plan</span> |
39 |
| - {/if} |
40 |
| - </h4> |
41 |
| - <p class="u-color-text-offline u-small"> |
42 |
| - {tierFree.description} |
43 |
| - </p> |
44 |
| - <p> |
45 |
| - {formatCurrency(freePlan?.price ?? 0)} |
46 |
| - </p> |
47 |
| - </div> |
48 |
| - </svelte:fragment> |
49 |
| - </LabelCard> |
50 |
| - </li> |
51 |
| - |
52 |
| - <li> |
53 |
| - <LabelCard |
54 |
| - name="plan" |
55 |
| - disabled={!selfService} |
56 |
| - bind:group={billingPlan} |
57 |
| - value={BillingPlan.PRO} |
58 |
| - padding={1.5}> |
59 |
| - <svelte:fragment slot="custom" let:disabled> |
60 |
| - <div |
61 |
| - class="u-flex u-flex-vertical u-gap-4 u-width-full-line" |
62 |
| - class:u-opacity-50={disabled}> |
63 |
| - <h4 class="body-text-2 u-bold"> |
64 |
| - {tierPro.name} |
65 |
| - {#if $organization?.billingPlan === BillingPlan.PRO && !isNewOrg} |
66 |
| - <span class="inline-tag">Current plan</span> |
67 |
| - {/if} |
68 |
| - </h4> |
69 |
| - <p class="u-color-text-offline u-small"> |
70 |
| - {tierPro.description} |
71 |
| - </p> |
72 |
| - <p> |
73 |
| - {formatCurrency(proPlan?.price ?? 0)} per member/month + usage |
74 |
| - </p> |
75 |
| - </div> |
76 |
| - </svelte:fragment> |
77 |
| - </LabelCard> |
78 |
| - </li> |
79 |
| - <li> |
80 |
| - <LabelCard |
81 |
| - name="plan" |
82 |
| - bind:group={billingPlan} |
83 |
| - value={BillingPlan.SCALE} |
84 |
| - padding={1.5} |
85 |
| - disabled={!selfService}> |
86 |
| - <svelte:fragment slot="custom" let:disabled> |
87 |
| - <div |
88 |
| - class="u-flex u-flex-vertical u-gap-4 u-width-full-line" |
89 |
| - class:u-opacity-50={disabled}> |
90 |
| - <h4 class="body-text-2 u-bold"> |
91 |
| - {tierScale.name} |
92 |
| - {#if $organization?.billingPlan === BillingPlan.SCALE && !isNewOrg} |
93 |
| - <span class="inline-tag">Current plan</span> |
94 |
| - {/if} |
95 |
| - </h4> |
96 |
| - <p class="u-color-text-offline u-small"> |
97 |
| - {tierScale.description} |
98 |
| - </p> |
99 |
| - <p> |
100 |
| - {formatCurrency(scalePlan?.price ?? 0)} per month + usage |
101 |
| - </p> |
102 |
| - </div> |
103 |
| - </svelte:fragment> |
104 |
| - </LabelCard> |
105 |
| - </li> |
| 17 | + {#each $plansInfo.entries() as [tier, plan] (tier)} |
| 18 | + <li> |
| 19 | + <LabelCard |
| 20 | + name="plan" |
| 21 | + bind:group={billingPlan} |
| 22 | + disabled={anyOrgFree || !selfService} |
| 23 | + value={tier} |
| 24 | + tooltipShow={anyOrgFree} |
| 25 | + tooltipText="You are limited to 1 Free organization per account." |
| 26 | + padding={1.5}> |
| 27 | + <svelte:fragment slot="custom" let:disabled> |
| 28 | + <div |
| 29 | + class="u-flex u-flex-vertical u-gap-4 u-width-full-line" |
| 30 | + class:u-opacity-50={disabled}> |
| 31 | + <h4 class="body-text-2 u-bold"> |
| 32 | + {plan.name} |
| 33 | + {#if isFreeTier($organization?.billingPlan) && !isNewOrg} |
| 34 | + <span class="inline-tag">Current plan</span> |
| 35 | + {/if} |
| 36 | + </h4> |
| 37 | + <p class="u-color-text-offline u-small"> |
| 38 | + {plan.desc} |
| 39 | + </p> |
| 40 | + <p> |
| 41 | + {formatCurrency(plan?.price ?? 0)} |
| 42 | + </p> |
| 43 | + </div> |
| 44 | + </svelte:fragment> |
| 45 | + </LabelCard> |
| 46 | + </li> |
| 47 | + {/each} |
106 | 48 | </ul>
|
107 | 49 | {/if}
|
0 commit comments