Skip to content

Commit

Permalink
Merge pull request #721 from appwrite/fix-trial-date
Browse files Browse the repository at this point in the history
Fixes issue where a negative number would prevent the TRIAL pill from…
  • Loading branch information
christyjacob4 authored Jan 13, 2024
2 parents 92e7f47 + 82f27c7 commit 50865bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/stores/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { cachedStore } from '$lib/helpers/cache';
import { Query, type Models } from '@appwrite.io/console';
import { headerAlert } from './headerAlert';
import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte';
import { diffDays } from '$lib/helpers/date';
import { addNotification, notifications } from './notifications';
import { goto } from '$app/navigation';
import { base } from '$app/paths';
Expand Down Expand Up @@ -161,7 +160,12 @@ export function calculateTrialDay(org: Organization) {
if (org?.billingPlan === BillingPlan.STARTER) return false;
const endDate = new Date(org?.billingStartDate);
const today = new Date();
const days = diffDays(today, endDate);

let diffTime = endDate.getTime() - today.getTime();
diffTime = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1;

const days = diffTime < 1 ? 0 : diffTime;

daysLeftInTrial.set(days);
return days;
}
Expand Down

3 comments on commit 50865bf

@vercel
Copy link

@vercel vercel bot commented on 50865bf Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

console-cloud – ./

console-cloud.vercel.app
console-cloud-git-main-appwrite.vercel.app
console-cloud-appwrite.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 50865bf Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

console-preview – ./

console-next.vercel.app
console-preview-appwrite.vercel.app
console-preview-git-main-appwrite.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 50865bf Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.