1 import { c } from 'ttag';
3 import type { Domain, Organization } from '@proton/shared/lib/interfaces';
4 import { type OrganizationKeyInfo, validateOrganizationKey } from '@proton/shared/lib/organization/helper';
6 export const getDomainError = () => {
7 return c('Error').t`Please configure a custom domain before adding users to your organization.`;
10 export const getDomainAddressError = () => {
11 return c('Error').t`Please configure a custom domain before adding addresses.`;
14 const validateAddUser = ({
18 disableStorageValidation,
19 disableDomainValidation,
20 disableAddressValidation,
24 organization: Organization | undefined;
25 verifiedDomains: Domain[];
26 disableStorageValidation?: boolean;
27 disableDomainValidation?: boolean;
28 disableAddressValidation?: boolean;
29 organizationKeyInfo: OrganizationKeyInfo;
39 } = organization || {};
41 if (MaxMembers === 1) {
42 return c('Error').t`Please upgrade to a business plan with more than 1 user to manage multiple users.`;
45 return c('Error').t`Please enable multi-user support before adding users to your organization.`;
47 if (!disableDomainValidation && !verifiedDomains.length) {
48 return getDomainError();
50 if (MaxMembers - UsedMembers < 1) {
51 return c('Error').t`You have used all users in your plan. Please upgrade your plan to add a new user.`;
53 if (!disableAddressValidation && MaxAddresses - UsedAddresses < 1) {
54 return c('Error').t`You have used all addresses in your plan. Please upgrade your plan to add a new address.`;
56 if (!disableStorageValidation && MaxSpace - AssignedSpace < 1) {
57 return c('Error').t`All storage space has been allocated. Please reduce storage allocated to other users.`;
60 const result = validateOrganizationKey(organizationKeyInfo);
67 export default validateAddUser;