Fix: hide globe map when agent has 0 traffic (bandwidth_down+up = 0), filter country entries with zero bytes
This commit is contained in:
1 parent
ab5bb1fd11
commit
a44206c112
1 file changed
+10
-2
@@ -50,10 +50,18 @@ export default function SummaryPage() {
|
||||
|
||||
const mapData = useMemo(() => {
|
||||
if (!countries.data) return [];
|
||||
|
||||
// Jika summary menunjukkan tidak ada traffic sama sekali, jangan tampilkan globe
|
||||
const totalTraffic = (summary.data?.bandwidth_down || 0) + (summary.data?.bandwidth_up || 0);
|
||||
if (totalTraffic === 0) return [];
|
||||
|
||||
const origin = getOriginLocation();
|
||||
|
||||
return countries.data.reduce((acc: any[], row) => {
|
||||
// Hanya tampilkan negara yang punya traffic aktual > 0
|
||||
const traffic = (row.download || 0) + (row.upload || 0);
|
||||
if (traffic === 0) return acc;
|
||||
|
||||
const dest = getDestinationLocation(row.country_code, row.country_name);
|
||||
if (dest) {
|
||||
acc.push({
|
||||
@@ -63,7 +71,7 @@ export default function SummaryPage() {
|
||||
endLng: dest.lng,
|
||||
fromLabel: origin.label,
|
||||
toLabel: dest.label,
|
||||
value: row.download + row.upload,
|
||||
value: traffic,
|
||||
download: row.download,
|
||||
upload: row.upload,
|
||||
countryCode: row.country_code
|
||||
@@ -71,7 +79,7 @@ export default function SummaryPage() {
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}, [countries.data]);
|
||||
}, [countries.data, summary.data]);
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
|
||||
Reference in new issue
Block a user