diff --git a/packages/client/src/components/Article/MainButton/index.js b/packages/client/src/components/Article/MainButton/index.js index 6f1f4e0afb..a933c7f74a 100644 --- a/packages/client/src/components/Article/MainButton/index.js +++ b/packages/client/src/components/Article/MainButton/index.js @@ -180,6 +180,7 @@ const ArticleMainButtonContent = (props) => { parentRoomType, isFolder, + showWarningDialog, } = props; const navigate = useNavigate(); @@ -283,7 +284,7 @@ const ArticleMainButtonContent = (props) => { const onInvite = React.useCallback((e) => { const type = e.action; - if (isGracePeriod) { + if (showWarningDialog(type)) { setInviteUsersWarningDialogVisible(true); return; } @@ -901,6 +902,7 @@ export default inject( versionHistoryStore, userStore, currentTariffStatusStore, + currentQuotaStore, }) => { const { showArticleLoader } = clientLoadingStore; const { mainButtonMobileVisible } = filesStore; @@ -939,6 +941,7 @@ export default inject( const { isAdmin, isOwner, isRoomAdmin } = userStore.user; const { isGracePeriod } = currentTariffStatusStore; + const { showWarningDialog } = currentQuotaStore; const { setOformFromFolderId, oformsFilter } = oformsStore; const { mainButtonItemsList } = pluginStore; @@ -997,6 +1000,8 @@ export default inject( isFolder, selectFileFormRoomDialogVisible, setSelectFileFormRoomDialogVisible, + + showWarningDialog, }; }, )( diff --git a/packages/client/src/store/ContextOptionsStore.js b/packages/client/src/store/ContextOptionsStore.js index 9d0ddf6fd1..989b245927 100644 --- a/packages/client/src/store/ContextOptionsStore.js +++ b/packages/client/src/store/ContextOptionsStore.js @@ -139,6 +139,7 @@ class ContextOptionsStore { pluginStore; infoPanelStore; currentTariffStatusStore; + currentQuotaStore; userStore; clientLoadingStore; @@ -160,6 +161,7 @@ class ContextOptionsStore { pluginStore, infoPanelStore, currentTariffStatusStore, + currentQuotaStore, userStore, clientLoadingStore, ) { @@ -179,6 +181,7 @@ class ContextOptionsStore { this.pluginStore = pluginStore; this.infoPanelStore = infoPanelStore; this.currentTariffStatusStore = currentTariffStatusStore; + this.currentQuotaStore = currentQuotaStore; this.userStore = userStore; this.clientLoadingStore = clientLoadingStore; } @@ -2104,7 +2107,7 @@ class ContextOptionsStore { const type = e.item["data-type"]; - if (this.currentTariffStatusStore.isGracePeriod) { + if (this.currentQuotaStore.showWarningDialog(type)) { setInviteUsersWarningDialogVisible(true); return; } diff --git a/packages/client/src/store/index.js b/packages/client/src/store/index.js index c63b3018a2..b8225f1cfa 100644 --- a/packages/client/src/store/index.js +++ b/packages/client/src/store/index.js @@ -234,6 +234,7 @@ const contextOptionsStore = new ContextOptionsStore( pluginStore, infoPanelStore, currentTariffStatusStore, + currentQuotaStore, userStore, clientLoadingStore, ); diff --git a/packages/shared/store/CurrentQuotaStore.ts b/packages/shared/store/CurrentQuotaStore.ts index f43e918729..ccf36e2c8c 100644 --- a/packages/shared/store/CurrentQuotaStore.ts +++ b/packages/shared/store/CurrentQuotaStore.ts @@ -34,7 +34,7 @@ import { import { toastr } from "../components/toast"; import { TData } from "../components/toast/Toast.type"; -import { PortalFeaturesLimitations } from "../enums"; +import { EmployeeType, PortalFeaturesLimitations } from "../enums"; import api from "../api"; import { TPaymentFeature, TPaymentQuota } from "../api/portal/types"; import { @@ -49,19 +49,25 @@ import { } from "../constants"; import { Nullable } from "../types"; import { UserStore } from "./UserStore"; - +import { CurrentTariffStatusStore } from "./CurrentTariffStatusStore"; class CurrentQuotasStore { currentPortalQuota: Nullable = null; userStore: UserStore | null = null; + currentTariffStatusStore: CurrentTariffStatusStore | null = null; + currentPortalQuotaFeatures: TPaymentFeature[] = []; isLoaded = false; - constructor(userStoreConst: UserStore) { + constructor( + userStoreConst: UserStore, + currentTariffStatusStore: CurrentTariffStatusStore, + ) { makeAutoObservable(this); this.userStore = userStoreConst; + this.currentTariffStatusStore = currentTariffStatusStore; } setIsLoaded = (isLoaded: boolean) => { @@ -274,6 +280,17 @@ class CurrentQuotasStore { ); } + get isPaidUserLimit() { + return this.addedManagersCount >= this.maxCountManagersByQuota; + } + + showWarningDialog = (type: number) => { + if (type && this.isPaidUserLimit && type !== EmployeeType.Guest) + return true; + + return this.currentTariffStatusStore?.isGracePeriod; + }; + get showUserPersonalQuotaBar() { const personalQuotaLimitReached = this.userStore?.personalQuotaLimitReached; diff --git a/packages/shared/store/index.ts b/packages/shared/store/index.ts index 5f8295bda2..c09c614dbb 100644 --- a/packages/shared/store/index.ts +++ b/packages/shared/store/index.ts @@ -36,9 +36,12 @@ import { SettingsStore } from "./SettingsStore"; export const userStore = new UserStore(); export const tfaStore = new TfaStore(); export const bannerStore = new BannerStore(); -export const currentQuotaStore = new CurrentQuotasStore(userStore); export const paymentQuotasStore = new PaymentQuotasStore(); export const currentTariffStatusStore = new CurrentTariffStatusStore(); +export const currentQuotaStore = new CurrentQuotasStore( + userStore, + currentTariffStatusStore, +); export const settingsStore = new SettingsStore(); export const authStore = new AuthStore( userStore,