Skip to content

Commit a72e830

Browse files
ButteryCrumpetRokt33r
authored andcommitted
fix end date calculation
1 parent 6d2d710 commit a72e830

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

src/cloud/components/settings/TeamSubLimit.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ const TeamSubLimit = ({
8787
style={{ width: `${currentSubInfo.info.rate}%` }}
8888
/>
8989
</div>
90-
{currentSubInfo.info.trialIsOver && (
91-
<p>{translate(lngKeys.SettingsSubLimitTrialEnd)}</p>
92-
)}
9390
<p className='note-limit'>
9491
{translate(lngKeys.SettingsSubLimitTrialDate, {
9592
date: format(currentSubInfo.info.endDate, 'dd MMM, yyyy'),

src/cloud/lib/stores/pageStore/store.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,13 @@ function usePageDataStore(pageProps: any, navigatingBetweenPage: boolean) {
209209
}
210210

211211
const { remaining, max, end } = remainingTrialInfo(team)
212-
const rate = ((max - remaining) / max) * 100
213-
const progressLabel = `${max - remaining}/${max}`
214-
215212
return {
216213
trialing: false,
217214
info: {
218215
trialIsOver: remaining < 1,
219-
progressLabel,
216+
progressLabel: `${max - remaining}/${max}`,
220217
endDate: end,
221-
rate,
218+
rate: ((max - remaining) / max) * 100,
222219
},
223220
}
224221
}, [subscription, team])

src/cloud/lib/subscription.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { differenceInDays, isBefore, add, sub } from 'date-fns'
1+
import { differenceInDays, isBefore, add } from 'date-fns'
22
import { SerializedDoc } from '../interfaces/db/doc'
33
import { SerializedSubscription } from '../interfaces/db/subscription'
44
import { SerializedTeam } from '../interfaces/db/team'
55
import { SerializedUserTeamPermissions } from '../interfaces/db/userTeamPermissions'
66
import { filterIter } from './utils/iterator'
77

8-
export const freePlanDocLimit = 30
8+
export const freePlanDocLimit = Infinity
99
export const freeTrialPeriodDays = 7
1010

11-
export const freePlanStorageMb = 5
11+
export const freePlanStorageMb = 1000
1212
export const standardPlanStorageMb = 1000
1313
export const proPlanStorageMb = 10000
1414

15-
export const revisionHistoryFreeDays = 3
15+
export const revisionHistoryFreeDays = 7
1616
export const revisionHistoryStandardDays = 7
1717
export const newTeamDiscountDays = 7
1818

@@ -25,9 +25,7 @@ export const freePlanSmartViewPerDashboardLimit = 4
2525
export const freePlanDashboardPerUserPerTeamLimit = 1
2626

2727
export const initialTrialLength = { days: 14 }
28-
export const initialTrialCutoff = new Date(
29-
process.env.LEGECY_CUTOFF || Date.now()
30-
)
28+
export const legacyCutoff = new Date(process.env.LEGACY_CUTOFF || Date.now())
3129

3230
export function isTimeEligibleForDiscount(team: { createdAt: string }) {
3331
if (
@@ -41,13 +39,13 @@ export function isTimeEligibleForDiscount(team: { createdAt: string }) {
4139

4240
export function remainingTrialInfo(team: SerializedTeam) {
4341
const createDate = new Date(team.createdAt)
44-
const legacy = isBefore(createDate, initialTrialCutoff)
45-
const endDate = legacy
46-
? add(initialTrialCutoff, initialTrialLength)
47-
: add(createDate, initialTrialLength)
48-
const startDate = legacy ? initialTrialCutoff : createDate
42+
const startDate = isBefore(createDate, legacyCutoff)
43+
? legacyCutoff
44+
: createDate
45+
const endDate = add(startDate, initialTrialLength)
46+
4947
return {
50-
remaining: Math.max(0, differenceInDays(endDate, startDate)),
48+
remaining: Math.max(0, differenceInDays(endDate, new Date())),
5149
max: initialTrialLength.days,
5250
end: endDate,
5351
}

0 commit comments

Comments
 (0)