Client/Shared: Added method separation.
This commit is contained in:
parent
6eaaa13e70
commit
803c44e47a
@ -127,12 +127,12 @@ class PaymentStore {
|
||||
basicSettings = async () => {
|
||||
if (!this.currentTariffStatusStore || !this.currentQuotaStore) return;
|
||||
|
||||
const { setPortalTariff, setPayerInfo } = this.currentTariffStatusStore;
|
||||
const { fetchPortalTariff, setPayerInfo } = this.currentTariffStatusStore;
|
||||
const { addedManagersCount } = this.currentQuotaStore;
|
||||
|
||||
this.setIsUpdatingBasicSettings(true);
|
||||
|
||||
const requests = [setPortalTariff()];
|
||||
const requests = [fetchPortalTariff()];
|
||||
|
||||
if (this.isAlreadyPaid) requests.push(this.setPaymentAccount());
|
||||
else requests.push(this.getBasicPaymentLink(addedManagersCount));
|
||||
|
@ -145,7 +145,7 @@ class StorageManagement {
|
||||
};
|
||||
|
||||
updateQuotaInfo = async (type) => {
|
||||
const { getTenantExtra } = this.authStore;
|
||||
const { fetchPortalQuota } = this.currentQuotaStore;
|
||||
const { getFilesListItems } = this.filesStore;
|
||||
const { usersStore } = this.peopleStore;
|
||||
const { getPeopleListItem } = usersStore;
|
||||
@ -156,7 +156,7 @@ class StorageManagement {
|
||||
const roomFilterData = RoomsFilter.getDefault();
|
||||
roomFilterData.pageCount = FILTER_COUNT;
|
||||
|
||||
const requests = [getTenantExtra()];
|
||||
const requests = [fetchPortalQuota()];
|
||||
|
||||
type === "user"
|
||||
? requests.push(getUserList(userFilterData))
|
||||
|
@ -226,25 +226,37 @@ class AuthStore {
|
||||
return this.tenantExtra?.opensource;
|
||||
}
|
||||
|
||||
fetchTenantExtra = (refresh: boolean) => {
|
||||
return getPortalTenantExtra(refresh).then((result) => {
|
||||
if (!result) return;
|
||||
|
||||
const { tariff, quota, ...tenantExtra } = result;
|
||||
|
||||
this.tenantExtra = tenantExtra;
|
||||
});
|
||||
};
|
||||
|
||||
getTenantExtra = async () => {
|
||||
let refresh = false;
|
||||
|
||||
if (window.location.search === "?complete=true") {
|
||||
window.history.replaceState({}, document.title, window.location.pathname);
|
||||
refresh = true;
|
||||
}
|
||||
const user = this.userStore?.user?.isVisitor;
|
||||
|
||||
const result = await getPortalTenantExtra(refresh);
|
||||
const request = [];
|
||||
|
||||
if (!result) return;
|
||||
request.push(this.currentTariffStatusStore?.fetchPortalTariff(refresh));
|
||||
|
||||
const { tariff, quota, ...tenantExtra } = result;
|
||||
if (!user) {
|
||||
request.push(
|
||||
this.currentQuotaStore?.fetchPortalQuota(refresh),
|
||||
this.fetchTenantExtra(refresh),
|
||||
);
|
||||
}
|
||||
|
||||
runInAction(() => {
|
||||
this.tenantExtra = { ...tenantExtra };
|
||||
});
|
||||
|
||||
this.currentQuotaStore?.setPortalQuotaValue(quota);
|
||||
this.currentTariffStatusStore?.setPortalTariffValue(tariff);
|
||||
await Promise.all(request);
|
||||
};
|
||||
|
||||
setLanguage() {
|
||||
|
@ -338,18 +338,12 @@ class CurrentQuotasStore {
|
||||
});
|
||||
};
|
||||
|
||||
setPortalQuota = async () => {
|
||||
try {
|
||||
const res = await api.portal.getPortalQuota();
|
||||
|
||||
if (!res) return;
|
||||
|
||||
fetchPortalQuota = async (refresh: boolean) => {
|
||||
return api.portal.getPortalQuota(refresh).then((res) => {
|
||||
this.setPortalQuotaValue(res);
|
||||
|
||||
this.setIsLoaded(true);
|
||||
} catch (e) {
|
||||
toastr.error(e as TData);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
setUserQuota = async (quota: string | number, t: (key: string) => string) => {
|
||||
|
@ -163,19 +163,10 @@ class CurrentTariffStatusStore {
|
||||
return getDaysLeft(this.dueDate);
|
||||
}
|
||||
|
||||
setPortalTariffValue = async (res: TPortalTariff) => {
|
||||
this.portalTariffStatus = res;
|
||||
|
||||
this.setIsLoaded(true);
|
||||
};
|
||||
|
||||
setPortalTariff = async () => {
|
||||
const res = await api.portal.getPortalTariff();
|
||||
|
||||
if (!res) return;
|
||||
|
||||
runInAction(() => {
|
||||
fetchPortalTariff = async (refresh?: boolean) => {
|
||||
return api.portal.getPortalTariff(refresh).then((res) => {
|
||||
this.portalTariffStatus = res;
|
||||
this.setIsLoaded(true);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user