From 50f593032b4868261f26a70bae6b2492d216006d Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 6 Aug 2024 10:12:27 +0300 Subject: [PATCH] Deleted useless request. --- .../src/components/Article/Body/Items.js | 6 ++-- .../components/PrivateRouteWrapper/index.tsx | 13 +++---- .../StandaloneComponents/BenefitsContainer.js | 5 ++- .../StandaloneComponents/ContactContainer.js | 14 ++++---- .../client/src/components/TariffBar/index.js | 7 ++-- .../Layout/Article/Body/index.js | 4 +-- .../client/src/store/ProfileActionsStore.js | 4 ++- packages/client/src/store/index.js | 1 + packages/management/src/App.tsx | 6 ++-- .../src/Layout/Article/Body/index.tsx | 4 +-- packages/management/src/store/index.ts | 3 ++ packages/shared/api/portal/types.ts | 2 ++ packages/shared/store/AuthStore.ts | 36 ++++++------------- .../shared/store/CurrentTariffStatusStore.ts | 14 ++++---- 14 files changed, 56 insertions(+), 63 deletions(-) diff --git a/packages/client/src/components/Article/Body/Items.js b/packages/client/src/components/Article/Body/Items.js index 8f5d263efe..f4b212e4fa 100644 --- a/packages/client/src/components/Article/Body/Items.js +++ b/packages/client/src/components/Article/Body/Items.js @@ -421,9 +421,11 @@ export default inject( clientLoadingStore, userStore, settingsStore, + currentTariffStatusStore, }) => { - const { isCommunity, isPaymentPageAvailable, currentDeviceType } = - authStore; + const { isPaymentPageAvailable, currentDeviceType } = authStore; + const { isCommunity } = currentTariffStatusStore; + const { showText, currentColorScheme } = settingsStore; const { diff --git a/packages/client/src/components/PrivateRouteWrapper/index.tsx b/packages/client/src/components/PrivateRouteWrapper/index.tsx index 41320755d6..ae2419dffc 100644 --- a/packages/client/src/components/PrivateRouteWrapper/index.tsx +++ b/packages/client/src/components/PrivateRouteWrapper/index.tsx @@ -74,16 +74,11 @@ const PrivateRouteWrapper = ({ export default inject( ({ authStore, settingsStore, userStore, currentTariffStatusStore }) => { - const { - isAuthenticated, - isLoaded, - isAdmin, + const { isAuthenticated, isLoaded, isAdmin, isLogout } = authStore; + + const { isNotPaidPeriod, isCommunity, isEnterprise } = + currentTariffStatusStore; - isLogout, - isCommunity, - isEnterprise, - } = authStore; - const { isNotPaidPeriod } = currentTariffStatusStore; const { user } = userStore; const { diff --git a/packages/client/src/components/StandaloneComponents/BenefitsContainer.js b/packages/client/src/components/StandaloneComponents/BenefitsContainer.js index 53be5b0f01..6aec3427b7 100644 --- a/packages/client/src/components/StandaloneComponents/BenefitsContainer.js +++ b/packages/client/src/components/StandaloneComponents/BenefitsContainer.js @@ -109,10 +109,9 @@ const BenefitsContainer = ({ isTrial, isEnterprise }) => { }; export default inject( - ({ authStore, currentQuotaStore, paymentQuotasStore }) => { - const { isEnterprise } = authStore; - + ({ currentTariffStatusStore, currentQuotaStore, paymentQuotasStore }) => { const { portalPaymentQuotasFeatures } = paymentQuotasStore; + const { isEnterprise } = currentTariffStatusStore; const { isTrial } = currentQuotaStore; return { diff --git a/packages/client/src/components/StandaloneComponents/ContactContainer.js b/packages/client/src/components/StandaloneComponents/ContactContainer.js index f75b5b30d3..6cc90123ee 100644 --- a/packages/client/src/components/StandaloneComponents/ContactContainer.js +++ b/packages/client/src/components/StandaloneComponents/ContactContainer.js @@ -149,9 +149,11 @@ const ContactContainer = (props) => { ); }; -export default inject(({ authStore, settingsStore, paymentStore }) => { - const { isCommunity } = authStore; - const { helpUrl, salesEmail } = paymentStore; - const { theme } = settingsStore; - return { helpUrl, salesEmail, theme, isCommunity }; -})(observer(ContactContainer)); +export default inject( + ({ currentTariffStatusStore, settingsStore, paymentStore }) => { + const { isCommunity } = currentTariffStatusStore; + const { helpUrl, salesEmail } = paymentStore; + const { theme } = settingsStore; + return { helpUrl, salesEmail, theme, isCommunity }; + }, +)(observer(ContactContainer)); diff --git a/packages/client/src/components/TariffBar/index.js b/packages/client/src/components/TariffBar/index.js index cbaa05b3cc..769cc8c491 100644 --- a/packages/client/src/components/TariffBar/index.js +++ b/packages/client/src/components/TariffBar/index.js @@ -134,11 +134,7 @@ export default inject( currentQuotaStore, currentTariffStatusStore, }) => { - const { - isPaymentPageAvailable, - - isEnterprise, - } = authStore; + const { isPaymentPageAvailable } = authStore; const { isFreeTariff, isNonProfit, isTrial } = currentQuotaStore; const { isGracePeriod, @@ -146,6 +142,7 @@ export default inject( isLicenseDateExpired, paymentDate, trialDaysLeft, + isEnterprise, } = currentTariffStatusStore; const { standalone } = settingsStore; diff --git a/packages/client/src/pages/PortalSettings/Layout/Article/Body/index.js b/packages/client/src/pages/PortalSettings/Layout/Article/Body/index.js index 2ec0b89de1..3c45a9ac93 100644 --- a/packages/client/src/pages/PortalSettings/Layout/Article/Body/index.js +++ b/packages/client/src/pages/PortalSettings/Layout/Article/Body/index.js @@ -346,8 +346,8 @@ export default inject( currentTariffStatusStore, }) => { const { isLoadedArticleBody, setIsLoadedArticleBody } = common; - const { isCommunity } = authStore; - const { isNotPaidPeriod } = currentTariffStatusStore; + + const { isNotPaidPeriod, isCommunity } = currentTariffStatusStore; const { user } = userStore; const { isOwner } = user; const { diff --git a/packages/client/src/store/ProfileActionsStore.js b/packages/client/src/store/ProfileActionsStore.js index dd60061443..ef6ed373b4 100644 --- a/packages/client/src/store/ProfileActionsStore.js +++ b/packages/client/src/store/ProfileActionsStore.js @@ -83,6 +83,7 @@ class ProfileActionsStore { pluginStore, userStore, settingsStore, + currentTariffStatusStore, ) { this.authStore = authStore; this.filesStore = filesStore; @@ -92,6 +93,7 @@ class ProfileActionsStore { this.pluginStore = pluginStore; this.userStore = userStore; this.settingsStore = settingsStore; + this.currentTariffStatusStore = currentTariffStatusStore; this.isShowLiveChat = this.getStateLiveChat(); @@ -248,7 +250,7 @@ class ProfileActionsStore { limitedAccessSpace, } = this.settingsStore; const isAdmin = this.authStore.isAdmin; - const isCommunity = this.authStore.isCommunity; + const isCommunity = this.currentTariffStatusStore.isCommunity; // const { isOwner } = this.userStore.user; // const settingsModule = modules.find((module) => module.id === "settings"); diff --git a/packages/client/src/store/index.js b/packages/client/src/store/index.js index c63b3018a2..8d2478efe5 100644 --- a/packages/client/src/store/index.js +++ b/packages/client/src/store/index.js @@ -257,6 +257,7 @@ const profileActionsStore = new ProfileActionsStore( pluginStore, userStore, settingsStore, + currentTariffStatusStore, ); peopleStore.profileActionsStore = profileActionsStore; diff --git a/packages/management/src/App.tsx b/packages/management/src/App.tsx index dedebe9254..74218e1e1a 100644 --- a/packages/management/src/App.tsx +++ b/packages/management/src/App.tsx @@ -57,10 +57,12 @@ let isPaymentPageUnavailable = true; let isBonusPageUnavailable = true; const App = observer(() => { - const { authStore, userStore, settingsStore } = useStore(); + const { authStore, userStore, settingsStore, currentTariffStatusStore } = + useStore(); const location = useLocation(); - const { init, isCommunity, isLoaded } = authStore; + const { init, isLoaded } = authStore; + const { isCommunity } = currentTariffStatusStore; const { setTheme, limitedAccessSpace, timezone } = settingsStore; window.timezone = timezone; diff --git a/packages/management/src/Layout/Article/Body/index.tsx b/packages/management/src/Layout/Article/Body/index.tsx index 01210ff2e8..270d8a26e3 100644 --- a/packages/management/src/Layout/Article/Body/index.tsx +++ b/packages/management/src/Layout/Article/Body/index.tsx @@ -52,9 +52,9 @@ const ArticleBodyContent = () => { const { t } = useTranslation(["Settings", "Common"]); - const { settingsStore, authStore } = useStore(); + const { settingsStore, currentTariffStatusStore } = useStore(); - const { isCommunity } = authStore; + const { isCommunity } = currentTariffStatusStore; const { toggleArticleOpen, setIsBurgerLoading, currentColorScheme } = settingsStore; diff --git a/packages/management/src/store/index.ts b/packages/management/src/store/index.ts index c45345d0d0..47918b9fcb 100644 --- a/packages/management/src/store/index.ts +++ b/packages/management/src/store/index.ts @@ -37,10 +37,12 @@ const { userStore, bannerStore, settingsStore, + currentTariffStatusStore, }: { userStore: UserStore; bannerStore: BannerStore; authStore: any; + currentTariffStatusStore: any; settingsStore: SettingsStore; } = store; @@ -49,6 +51,7 @@ export class RootStore { userStore = userStore; bannerStore = bannerStore; settingsStore = settingsStore; + currentTariffStatusStore = currentTariffStatusStore; spacesStore = new SpacesStore(this.settingsStore); } diff --git a/packages/shared/api/portal/types.ts b/packages/shared/api/portal/types.ts index 1dd34fcb05..04f7afa830 100644 --- a/packages/shared/api/portal/types.ts +++ b/packages/shared/api/portal/types.ts @@ -37,6 +37,8 @@ export type TPortalTariff = { customerId: string; portalStatus?: number; quotas: TQuotas[]; + enterprise: boolean; + openSource: boolean; }; export type TPaymentFeature = { diff --git a/packages/shared/store/AuthStore.ts b/packages/shared/store/AuthStore.ts index bb74be2169..644da9cba8 100644 --- a/packages/shared/store/AuthStore.ts +++ b/packages/shared/store/AuthStore.ts @@ -158,7 +158,7 @@ class AuthStore { updateTariff = async () => { this.setIsUpdatingTariff(true); - await this.getTenantExtra(); + await this.getPaymentInfo(); await this.currentTariffStatusStore?.setPayerInfo(); this.setIsUpdatingTariff(false); @@ -189,7 +189,7 @@ class AuthStore { requests.push( this.userStore?.init(i18n, this.settingsStore.culture).then(() => { if (!isPortalRestore) { - this.getTenantExtra(); + this.getPaymentInfo(); } }), ); @@ -227,28 +227,17 @@ class AuthStore { }); }; - get isEnterprise() { - this.currentTariffStatusStore?.setIsEnterprise( - this.tenantExtra?.enterprise || false, - ); - return this.tenantExtra?.enterprise; - } + // fetchTenantExtra = (refresh: boolean) => { + // return getPortalTenantExtra(refresh).then((result) => { + // if (!result) return; - get isCommunity() { - return this.tenantExtra?.opensource; - } + // const { tariff, quota, ...tenantExtra } = result; - fetchTenantExtra = (refresh: boolean) => { - return getPortalTenantExtra(refresh).then((result) => { - if (!result) return; + // this.tenantExtra = tenantExtra; + // }); + // }; - const { tariff, quota, ...tenantExtra } = result; - - this.tenantExtra = tenantExtra; - }); - }; - - getTenantExtra = async () => { + getPaymentInfo = async () => { let refresh = false; if (window.location.search === "?complete=true") { @@ -262,10 +251,7 @@ class AuthStore { request.push(this.currentTariffStatusStore?.fetchPortalTariff(refresh)); if (!user) { - request.push( - this.currentQuotaStore?.fetchPortalQuota(refresh), - this.fetchTenantExtra(refresh), - ); + request.push(this.currentQuotaStore?.fetchPortalQuota(refresh)); } await Promise.all(request); diff --git a/packages/shared/store/CurrentTariffStatusStore.ts b/packages/shared/store/CurrentTariffStatusStore.ts index 8e28088a53..81414a3b31 100644 --- a/packages/shared/store/CurrentTariffStatusStore.ts +++ b/packages/shared/store/CurrentTariffStatusStore.ts @@ -46,8 +46,6 @@ class CurrentTariffStatusStore { language: string = "en"; - isEnterprise: boolean = false; - constructor() { makeAutoObservable(this); } @@ -56,14 +54,18 @@ class CurrentTariffStatusStore { this.language = language; }; - setIsEnterprise = (isEnterprise: boolean) => { - this.isEnterprise = isEnterprise; - }; - setIsLoaded = (isLoaded: boolean) => { this.isLoaded = isLoaded; }; + get isEnterprise() { + return this.portalTariffStatus?.enterprise; + } + + get isCommunity() { + return this.portalTariffStatus?.openSource; + } + get isGracePeriod() { return this.portalTariffStatus?.state === TariffState.Delay; }