Skip to content

Commit

Permalink
🐛 (workspace) Read custom limits even without CUSTOM plan
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Dec 13, 2022
1 parent 656d1e3 commit fd6b94b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions packages/utils/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export const chatsLimit = {
price: 10,
},
},
[Plan.CUSTOM]: {
totalIncluded: 2000,
increaseStep: {
amount: 500,
price: 10,
},
},
[Plan.OFFERED]: { totalIncluded: infinity },
[Plan.LIFETIME]: { totalIncluded: infinity },
} as const
Expand All @@ -43,6 +50,13 @@ export const storageLimit = {
price: 2,
},
},
[Plan.CUSTOM]: {
totalIncluded: 2,
increaseStep: {
amount: 1,
price: 2,
},
},
[Plan.OFFERED]: { totalIncluded: 2 },
[Plan.LIFETIME]: { totalIncluded: 10 },
} as const
Expand All @@ -55,6 +69,9 @@ export const seatsLimit = {
[Plan.PRO]: {
totalIncluded: 5,
},
[Plan.CUSTOM]: {
totalIncluded: 2,
},
[Plan.OFFERED]: { totalIncluded: 2 },
[Plan.LIFETIME]: { totalIncluded: 8 },
} as const
Expand All @@ -64,8 +81,7 @@ export const getChatsLimit = ({
additionalChatsIndex,
customChatsLimit,
}: Pick<Workspace, 'additionalChatsIndex' | 'plan' | 'customChatsLimit'>) => {
if (plan === Plan.CUSTOM)
return customChatsLimit ?? chatsLimit[Plan.FREE].totalIncluded
if (customChatsLimit) return customChatsLimit
const { totalIncluded } = chatsLimit[plan]
const increaseStep =
plan === Plan.STARTER || plan === Plan.PRO
Expand All @@ -83,8 +99,7 @@ export const getStorageLimit = ({
Workspace,
'additionalStorageIndex' | 'plan' | 'customStorageLimit'
>) => {
if (plan === Plan.CUSTOM)
return customStorageLimit ?? storageLimit[Plan.FREE].totalIncluded
if (customStorageLimit) return customStorageLimit
const { totalIncluded } = storageLimit[plan]
const increaseStep =
plan === Plan.STARTER || plan === Plan.PRO
Expand All @@ -97,8 +112,7 @@ export const getSeatsLimit = ({
plan,
customSeatsLimit,
}: Pick<Workspace, 'plan' | 'customSeatsLimit'>) => {
if (plan === Plan.CUSTOM)
return customSeatsLimit ?? seatsLimit[Plan.FREE].totalIncluded
if (customSeatsLimit) return customSeatsLimit
return seatsLimit[plan].totalIncluded
}

Expand Down

0 comments on commit fd6b94b

Please sign in to comment.