Skip to content

Commit ef5d51b

Browse files
ButteryCrumpetRokt33r
authored andcommitted
exclude teams where trial=false from default trial
1 parent aa1a6c0 commit ef5d51b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/cloud/lib/subscription.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ export const freePlanDashboardPerUserPerTeamLimit = 1
2727
export const initialTrialLength = { days: 14 }
2828
export const legacyCutoff = new Date(process.env.LEGACY_CUTOFF || Date.now())
2929

30-
export function isTimeEligibleForDiscount(team: { createdAt: string }) {
31-
if (
32-
differenceInDays(Date.now(), new Date(team.createdAt)) < newTeamDiscountDays
33-
) {
34-
return true
35-
}
36-
37-
return false
30+
export function isTimeEligibleForDiscount(team: {
31+
createdAt: string
32+
trial: boolean
33+
}) {
34+
return (
35+
differenceInDays(Date.now(), new Date(team.createdAt)) <
36+
newTeamDiscountDays && team.trial
37+
)
3838
}
3939

4040
export function teamIsReadonly(
@@ -45,11 +45,7 @@ export function teamIsReadonly(
4545
return remainingTrialInfo(team).remaining < 1
4646
}
4747

48-
if (subscription.status === 'inactive') {
49-
return true
50-
}
51-
52-
return false
48+
return subscription.status === 'inactive'
5349
}
5450

5551
export function remainingTrialInfo(team: SerializedTeam) {
@@ -64,6 +60,14 @@ export function remainingTrialInfo(team: SerializedTeam) {
6460
const today = new Date()
6561
today.setUTCHours(0, 0, 0, 0)
6662

63+
if (!team.trial) {
64+
return {
65+
remaining: 0,
66+
max: initialTrialLength.days,
67+
end: endDate,
68+
}
69+
}
70+
6771
return {
6872
remaining: Math.max(0, differenceInDays(endDate, today)),
6973
max: initialTrialLength.days,

0 commit comments

Comments
 (0)