|
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'; |
7 | 6 | import { isCloud } from '$lib/system'; |
8 | | - import { upgradeURL } from '$lib/stores/billing'; |
| 7 | + import { getChangePlanUrl } from '$lib/stores/billing'; |
9 | 8 | import { hideNotification } from '$lib/helpers/notifications'; |
10 | 9 | import { backupsBannerId, showPolicyAlert } from '$lib/stores/database'; |
11 | 10 | import { IconX } from '@appwrite.io/pink-icons-svelte'; |
|
18 | 17 | </script> |
19 | 18 |
|
20 | 19 | {#if $showPolicyAlert && isCloud && $organization?.$id && page.url.pathname.match(/\/databases\/database-[^/]+$/)} |
21 | | - {@const isFreePlan = $organization?.billingPlan === BillingPlan.FREE} |
| 20 | + {@const areBackupsAvailable = $organization?.billingPlanDetails.backupsEnabled} |
22 | 21 |
|
23 | | - {@const subtitle = isFreePlan |
| 22 | + {@const subtitle = !areBackupsAvailable |
24 | 23 | ? 'Upgrade your plan to ensure your data stays safe and backed up' |
25 | 24 | : 'Protect your data by quickly adding a backup policy'} |
26 | 25 |
|
27 | | - {@const ctaText = isFreePlan ? 'Upgrade plan' : 'Create policy'} |
28 | | - {@const ctaURL = isFreePlan ? $upgradeURL : `${page.url.pathname}/backups`} |
| 26 | + {@const ctaText = !areBackupsAvailable ? 'Upgrade plan' : 'Create policy'} |
| 27 | + {@const ctaURL = !areBackupsAvailable |
| 28 | + ? getChangePlanUrl($organization.$id) |
| 29 | + : `${page.url.pathname}/backups`} |
29 | 30 |
|
30 | 31 | <HeaderAlert type="warning" title="Your database has no backup policy"> |
31 | 32 | <svelte:fragment>{subtitle}</svelte:fragment> |
|
35 | 36 | href={ctaURL} |
36 | 37 | secondary |
37 | 38 | fullWidthMobile |
38 | | - event={isFreePlan ? 'backup_banner_upgrade' : 'backup_banner_add'}> |
| 39 | + event={!areBackupsAvailable ? 'backup_banner_upgrade' : 'backup_banner_add'}> |
39 | 40 | <span class="text">{ctaText}</span> |
40 | 41 | </Button> |
41 | 42 |
|
|
0 commit comments