diff --git a/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js b/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js index 00c15e791..a6fe0fc5b 100644 --- a/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js +++ b/src/views/Base/BandwidthStatusCard/BandwidthStatusCard.js @@ -36,13 +36,15 @@ class BandwidthStatusCard extends React.Component { const {bandwidthText, hasError} = this.state; if (!hasError) { const {setBandwidth} = this.props; - if (bandwidthText) + if (bandwidthText) { setBandwidth(bandwidthText); + this.toggleShowChangeBandwidth(); + } else { setBandwidth("0M"); } } else { - toast.error("Error in form"); + toast.error("Please check the errors before submitting"); } }; @@ -53,10 +55,22 @@ class BandwidthStatusCard extends React.Component { */ changeBandwidthInput = (e) => { const inputValue = e.target.value; - const validateInput = validateSizeSuffix(inputValue); + let validateInput = false; + if (inputValue === "") { + validateInput = true; + } else if (inputValue) { + const splitValue = inputValue.split(":"); + if(splitValue.length === 1) { + validateInput = validateSizeSuffix(splitValue[0]); + }else if(splitValue.length === 2) { + const validateDownloadLimit = validateSizeSuffix(splitValue[0]); + const validateUploadLimit = validateSizeSuffix(splitValue[1]); + validateInput = validateDownloadLimit && validateUploadLimit; + } + } this.setState({ bandwidthText: inputValue, - hasError: (inputValue !== "" ? !validateInput : false) + hasError: !validateInput }) }; @@ -94,15 +108,14 @@ class BandwidthStatusCard extends React.Component {