diff --git a/resources/js/Components/Billing/BillingBanner.vue b/resources/js/Components/Billing/BillingBanner.vue index 6d9e686c..1df7fd9a 100644 --- a/resources/js/Components/Billing/BillingBanner.vue +++ b/resources/js/Components/Billing/BillingBanner.vue @@ -8,6 +8,7 @@ import { import { Link } from '@inertiajs/vue3'; import { computed } from 'vue'; import { + daysLeftInTrial, isBillingActivated, isBlocked, isFreePlan, @@ -45,7 +46,9 @@ const showFreeUpgradeBanner = computed(
- Your trial expires in X days. + + Your trial expires in {{ daysLeftInTrial() }} days. + To continue using all features & support the development of solidtime, please upgrade your plan. diff --git a/resources/js/utils/billing.ts b/resources/js/utils/billing.ts index b5119872..dbef354a 100644 --- a/resources/js/utils/billing.ts +++ b/resources/js/utils/billing.ts @@ -1,4 +1,5 @@ import { usePage } from '@inertiajs/vue3'; +import { getDayJsInstance } from '@/packages/ui/src/utils/time'; export function isBillingActivated() { const page = usePage<{ @@ -17,6 +18,22 @@ export function isInTrial() { return page.props.billing.has_trial; } + +export function daysLeftInTrial() { + const page = usePage<{ + billing: { + trial_until: string; + }; + }>(); + + return ( + getDayJsInstance()(page.props.billing.trial_until).diff( + getDayJsInstance()(), + 'days' + ) + 1 + ); +} + export function isBlocked() { const page = usePage<{ billing: {