diff --git a/src/lib/components/shadcn/card/card.svelte b/src/lib/components/shadcn/card/card.svelte index fa23ea19..18765498 100644 --- a/src/lib/components/shadcn/card/card.svelte +++ b/src/lib/components/shadcn/card/card.svelte @@ -9,7 +9,7 @@
diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 8de039b3..10d0a8e8 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -370,6 +370,23 @@ export function formatETFName(inputString) { } +// Function to add days to a given date +export function addDays(data, days, state) { + let result; + const createdDate = new Date(data?.user?.created); + + result = new Date(createdDate); + result.setDate(result.getDate() + days); + + if(state === 'date') { + return result; + } else { + const differenceInTime = result - createdDate; + const differenceInDays = differenceInTime / (1000 * 60 * 60 * 24); + return Math.abs(differenceInDays); + } +} + export function pageTransitionIn(node, { duration, screenWidth }) { if (screenWidth >= 640) { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a2b1702e..406cf737 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -3,7 +3,7 @@ import "../app.pcss"; import { Toaster } from 'svelte-french-toast'; - import {getImageURL} from '$lib/utils'; + import {getImageURL, addDays} from '$lib/utils'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; @@ -47,6 +47,7 @@ let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL; + const trialLeftDays = addDays(data, 7, ''); async function pushNotification() { Notification?.requestPermission()?.then(perm => { @@ -435,7 +436,7 @@ $: { {#if data?.user?.tier === 'Free' || data?.user?.freeTrial === true} -
+
Upgrade to Pro - Unlock all features of the platform and level up your trading. + {#if data?.user?.freeTrial === true} + You have only + {trialLeftDays} days + left on your free trial. Upgrade now for unlimited access to all features! + {:else} + Unlock all features of the platform and level up your trading. + {/if} diff --git a/src/routes/community/profile/+page.svelte b/src/routes/community/profile/+page.svelte index 17d6336a..110ea584 100644 --- a/src/routes/community/profile/+page.svelte +++ b/src/routes/community/profile/+page.svelte @@ -6,7 +6,7 @@ import { serialize } from 'object-to-formdata'; import { onMount, onDestroy } from 'svelte'; - import {getImageURL } from '$lib/utils'; + import {getImageURL, addDays } from '$lib/utils'; import {userRegion, setCache, getCache, newAvatar, numberOfUnreadNotification, postIdDeleted } from '$lib/store'; import toast from 'svelte-french-toast'; @@ -499,18 +499,8 @@ const changeTab = (state) => { } }; -// Function to add days to a given date -function addDays(days) { - // Original date from the data object - const createdDate = new Date(data?.user?.created); - const result = new Date(createdDate); - result.setDate(result.getDate() + days); - return result; -} - - -const trialEndDate = addDays(7); +const trialEndDate = addDays(data, 7, 'date'); onMount(async () => { diff --git a/src/routes/pricing/+page.svelte b/src/routes/pricing/+page.svelte index 36a5d5bc..2af2d2a9 100644 --- a/src/routes/pricing/+page.svelte +++ b/src/routes/pricing/+page.svelte @@ -234,7 +234,7 @@ async function purchasePlan() { -
+
Discount