2
0

🐛 (workspace) Read custom limits even without CUSTOM plan

This commit is contained in:
Baptiste Arnaud
2022-12-13 08:21:18 +01:00
parent 656d1e3cad
commit fd6b94bb1b

View File

@@ -23,6 +23,13 @@ export const chatsLimit = {
price: 10, price: 10,
}, },
}, },
[Plan.CUSTOM]: {
totalIncluded: 2000,
increaseStep: {
amount: 500,
price: 10,
},
},
[Plan.OFFERED]: { totalIncluded: infinity }, [Plan.OFFERED]: { totalIncluded: infinity },
[Plan.LIFETIME]: { totalIncluded: infinity }, [Plan.LIFETIME]: { totalIncluded: infinity },
} as const } as const
@@ -43,6 +50,13 @@ export const storageLimit = {
price: 2, price: 2,
}, },
}, },
[Plan.CUSTOM]: {
totalIncluded: 2,
increaseStep: {
amount: 1,
price: 2,
},
},
[Plan.OFFERED]: { totalIncluded: 2 }, [Plan.OFFERED]: { totalIncluded: 2 },
[Plan.LIFETIME]: { totalIncluded: 10 }, [Plan.LIFETIME]: { totalIncluded: 10 },
} as const } as const
@@ -55,6 +69,9 @@ export const seatsLimit = {
[Plan.PRO]: { [Plan.PRO]: {
totalIncluded: 5, totalIncluded: 5,
}, },
[Plan.CUSTOM]: {
totalIncluded: 2,
},
[Plan.OFFERED]: { totalIncluded: 2 }, [Plan.OFFERED]: { totalIncluded: 2 },
[Plan.LIFETIME]: { totalIncluded: 8 }, [Plan.LIFETIME]: { totalIncluded: 8 },
} as const } as const
@@ -64,8 +81,7 @@ export const getChatsLimit = ({
additionalChatsIndex, additionalChatsIndex,
customChatsLimit, customChatsLimit,
}: Pick<Workspace, 'additionalChatsIndex' | 'plan' | 'customChatsLimit'>) => { }: Pick<Workspace, 'additionalChatsIndex' | 'plan' | 'customChatsLimit'>) => {
if (plan === Plan.CUSTOM) if (customChatsLimit) return customChatsLimit
return customChatsLimit ?? chatsLimit[Plan.FREE].totalIncluded
const { totalIncluded } = chatsLimit[plan] const { totalIncluded } = chatsLimit[plan]
const increaseStep = const increaseStep =
plan === Plan.STARTER || plan === Plan.PRO plan === Plan.STARTER || plan === Plan.PRO
@@ -83,8 +99,7 @@ export const getStorageLimit = ({
Workspace, Workspace,
'additionalStorageIndex' | 'plan' | 'customStorageLimit' 'additionalStorageIndex' | 'plan' | 'customStorageLimit'
>) => { >) => {
if (plan === Plan.CUSTOM) if (customStorageLimit) return customStorageLimit
return customStorageLimit ?? storageLimit[Plan.FREE].totalIncluded
const { totalIncluded } = storageLimit[plan] const { totalIncluded } = storageLimit[plan]
const increaseStep = const increaseStep =
plan === Plan.STARTER || plan === Plan.PRO plan === Plan.STARTER || plan === Plan.PRO
@@ -97,8 +112,7 @@ export const getSeatsLimit = ({
plan, plan,
customSeatsLimit, customSeatsLimit,
}: Pick<Workspace, 'plan' | 'customSeatsLimit'>) => { }: Pick<Workspace, 'plan' | 'customSeatsLimit'>) => {
if (plan === Plan.CUSTOM) if (customSeatsLimit) return customSeatsLimit
return customSeatsLimit ?? seatsLimit[Plan.FREE].totalIncluded
return seatsLimit[plan].totalIncluded return seatsLimit[plan].totalIncluded
} }