-
Notifications
You must be signed in to change notification settings - Fork 387
/
TrialExpirationBanner.vue
61 lines (52 loc) · 1.94 KB
/
TrialExpirationBanner.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2024 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<v-alert border class="my-4 pb-5" variant="outlined" :color="expired ? 'error' : 'warning'" :title="title" closable>
<p class="text-body-2 mt-2 mb-4">
{{ info }} Upgrade to continue using Storj for your own projects.<br>
<strong>Note:</strong> You will continue to maintain access to projects that you are a member of.
</p>
<v-btn :color="expired ? 'error' : 'warning'" :prepend-icon="mdiArrowUpCircleOutline" @click="onUpgrade">
Upgrade
</v-btn>
</v-alert>
</template>
<script setup lang="ts">
import { computed } from 'vue';
import { VAlert, VBtn } from 'vuetify/components';
import { mdiArrowUpCircleOutline } from '@mdi/js';
import { ExpirationInfo } from '@/types/users';
import { useUsersStore } from '@/store/modules/usersStore';
import { useConfigStore } from '@/store/modules/configStore';
import { useAppStore } from '@/store/modules/appStore';
const usersStore = useUsersStore();
const configStore = useConfigStore();
const appStore = useAppStore();
const props = withDefaults(defineProps<{
expired: boolean
}>(), {
expired: false,
});
/**
* Returns dialog title based on expired status.
*/
const title = computed<string>(() => {
return props.expired ? 'Trial Expired' : 'Your Trial is Expiring Soon';
});
/**
* Returns expiration info based on expired status.
*/
const info = computed<string>(() => {
return props.expired ? `Your trial expired ${expirationInfo.value.days} days ago.` : `Only ${expirationInfo.value.days} days left in your trial.`;
});
/**
* Returns user free trial expiration info.
*/
const expirationInfo = computed<ExpirationInfo>(() => usersStore.state.user.getExpirationInfo(configStore.state.config.daysBeforeTrialEndNotification));
/**
* Starts upgrade account flow.
*/
function onUpgrade(): void {
appStore.toggleUpgradeFlow(true);
}
</script>