|
1 | 1 | <script lang="ts"> |
2 | 2 | import { page } from '$app/state'; |
3 | | - import { BillingPlan } from '$lib/constants'; |
4 | 3 | import { Button } from '$lib/elements/forms'; |
5 | 4 | import { organization } from '$lib/stores/organization'; |
6 | 5 | import { HeaderAlert } from '$lib/layout'; |
|
10 | 9 | import { backupsBannerId, showPolicyAlert } from '$lib/stores/database'; |
11 | 10 | import { IconX } from '@appwrite.io/pink-icons-svelte'; |
12 | 11 | import { Icon } from '@appwrite.io/pink-svelte'; |
| 12 | + import { isFreePlan } from '$lib/helpers/billing'; |
13 | 13 |
|
14 | 14 | function handleClose() { |
15 | 15 | showPolicyAlert.set(false); |
|
18 | 18 | </script> |
19 | 19 |
|
20 | 20 | {#if $showPolicyAlert && isCloud && $organization?.$id && page.url.pathname.match(/\/databases\/database-[^/]+$/)} |
21 | | - {@const isFreePlan = $organization?.billingPlan === BillingPlan.FREE} |
| 21 | + {@const isFree = isFreePlan($organization?.billingPlan)} |
22 | 22 |
|
23 | | - {@const subtitle = isFreePlan |
| 23 | + {@const subtitle = isFree |
24 | 24 | ? 'Upgrade your plan to ensure your data stays safe and backed up' |
25 | 25 | : 'Protect your data by quickly adding a backup policy'} |
26 | 26 |
|
27 | | - {@const ctaText = isFreePlan ? 'Upgrade plan' : 'Create policy'} |
28 | | - {@const ctaURL = isFreePlan ? $upgradeURL : `${page.url.pathname}/backups`} |
| 27 | + {@const ctaText = isFree ? 'Upgrade plan' : 'Create policy'} |
| 28 | + {@const ctaURL = isFree ? $upgradeURL : `${page.url.pathname}/backups`} |
29 | 29 |
|
30 | 30 | <HeaderAlert type="warning" title="Your database has no backup policy"> |
31 | 31 | <svelte:fragment>{subtitle}</svelte:fragment> |
|
35 | 35 | href={ctaURL} |
36 | 36 | secondary |
37 | 37 | fullWidthMobile |
38 | | - event={isFreePlan ? 'backup_banner_upgrade' : 'backup_banner_add'}> |
| 38 | + event={isFree ? 'backup_banner_upgrade' : 'backup_banner_add'}> |
39 | 39 | <span class="text">{ctaText}</span> |
40 | 40 | </Button> |
41 | 41 |
|
|
0 commit comments