1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-14 20:06:41 +02:00

fix: also check includedTraffic before calculating overage and showing warning (#7091)

## About the changes

Fixes a bug that would display the overage warning on
network/traffic-usage when included traffic was 0. (it assumed all
traffic was overage)


![image](https://github.com/Unleash/unleash/assets/707867/793f8cb2-7c1d-4f67-b0e9-45c32fcb78e6)
This commit is contained in:
David Leek 2024-05-21 12:41:19 +02:00 committed by GitHub
parent 4f46f03843
commit c14fc54e33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,20 +257,23 @@ export const NetworkTrafficUsage: VFC = () => {
useEffect(() => {
if (data) {
const usage = toTrafficUsageSum(data.datasets);
const calculatedOverageCost = calculateOverageCost(
usage,
includedTraffic,
);
setUsageTotal(usage);
setOverageCost(calculatedOverageCost);
setEstimatedMonthlyCost(
calculateEstimatedMonthlyCost(
period,
data.datasets,
if (includedTraffic > 0) {
const calculatedOverageCost = calculateOverageCost(
usage,
includedTraffic,
new Date(),
),
);
);
setOverageCost(calculatedOverageCost);
setEstimatedMonthlyCost(
calculateEstimatedMonthlyCost(
period,
data.datasets,
includedTraffic,
new Date(),
),
);
}
}
}, [data]);
@ -281,7 +284,7 @@ export const NetworkTrafficUsage: VFC = () => {
elseShow={
<>
<ConditionallyRender
condition={overageCost > 0}
condition={includedTraffic > 0 && overageCost > 0}
show={
<Alert severity='warning' sx={{ mb: 4 }}>
<b>Heads up!</b> You are currently consuming