1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01: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(() => { useEffect(() => {
if (data) { if (data) {
const usage = toTrafficUsageSum(data.datasets); const usage = toTrafficUsageSum(data.datasets);
const calculatedOverageCost = calculateOverageCost(
usage,
includedTraffic,
);
setUsageTotal(usage); setUsageTotal(usage);
setOverageCost(calculatedOverageCost); if (includedTraffic > 0) {
setEstimatedMonthlyCost( const calculatedOverageCost = calculateOverageCost(
calculateEstimatedMonthlyCost( usage,
period,
data.datasets,
includedTraffic, includedTraffic,
new Date(), );
), setOverageCost(calculatedOverageCost);
);
setEstimatedMonthlyCost(
calculateEstimatedMonthlyCost(
period,
data.datasets,
includedTraffic,
new Date(),
),
);
}
} }
}, [data]); }, [data]);
@ -281,7 +284,7 @@ export const NetworkTrafficUsage: VFC = () => {
elseShow={ elseShow={
<> <>
<ConditionallyRender <ConditionallyRender
condition={overageCost > 0} condition={includedTraffic > 0 && overageCost > 0}
show={ show={
<Alert severity='warning' sx={{ mb: 4 }}> <Alert severity='warning' sx={{ mb: 4 }}>
<b>Heads up!</b> You are currently consuming <b>Heads up!</b> You are currently consuming