Web: Client: Data Import: fix parseQuota function

This commit is contained in:
Vladimir Khvan 2024-06-11 16:31:30 +05:00
parent 9a512d739e
commit 9df3f21e9b
5 changed files with 11 additions and 19 deletions

View File

@ -55,7 +55,7 @@ const SelectUsersStep = ({
useEffect(() => {
setSearchValue("");
setQuota(parseQuota(t, quotaCharacteristics[1]));
setQuota(parseQuota(quotaCharacteristics[1]));
}, []);
const handleDataChange = (leftBoundary, rightBoundary) => {

View File

@ -88,7 +88,7 @@ const AddEmailsStep = (props) => {
checkedUsers.withEmail.length + checkedUsers.withoutEmail.length;
useEffect(() => {
setQuota(parseQuota(t, quotaCharacteristics[1]));
setQuota(parseQuota(quotaCharacteristics[1]));
}, []);
const totalUsedUsers =

View File

@ -59,7 +59,7 @@ const SelectUsersStep = (props) => {
useEffect(() => {
setSearchValue("");
setQuota(parseQuota(t, quotaCharacteristics[1]));
setQuota(parseQuota(quotaCharacteristics[1]));
}, []);
const handleDataChange = (leftBoundary, rightBoundary) => {

View File

@ -55,7 +55,7 @@ const SelectUsersStep = ({
useEffect(() => {
setSearchValue("");
setQuota(parseQuota(t, quotaCharacteristics[1]));
setQuota(parseQuota(quotaCharacteristics[1]));
}, []);
const handleDataChange = (leftBoundary, rightBoundary) => {

View File

@ -24,28 +24,20 @@
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import { PortalFeaturesLimitations } from "@docspace/shared/enums";
import { getConvertedSize } from "@docspace/shared/utils/common";
import { TFunciton, TQuota } from "../types";
import { TQuota } from "../types";
export const parseQuota = (t: TFunciton, quotaCharacteristics: TQuota) => {
export const parseQuota = (quotaCharacteristics: TQuota) => {
const maxValue = quotaCharacteristics.value;
const usedValue = quotaCharacteristics.used.value;
const usedValue = quotaCharacteristics.used!.value;
if (maxValue === PortalFeaturesLimitations.Unavailable) return;
if (maxValue === PortalFeaturesLimitations.Unavailable)
return { used: 0, max: null };
const isExistsMaxValue = maxValue !== PortalFeaturesLimitations.Limitless;
const resultingMaxValue =
quotaCharacteristics.type === "size" && isExistsMaxValue
? getConvertedSize(t, maxValue)
: isExistsMaxValue
? maxValue
: null;
const resultingMaxValue = isExistsMaxValue ? maxValue : null;
const resultingUsedValue =
quotaCharacteristics.type === "size"
? getConvertedSize(t, usedValue)
: usedValue;
const resultingUsedValue = usedValue;
return { used: resultingUsedValue, max: resultingMaxValue };
};