"use client"; import React from 'react'; import { ChartBarIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline'; export interface SimUsage { account: string; todayUsageKb: number; todayUsageMb: number; recentDaysUsage: Array<{ date: string; usageKb: number; usageMb: number; }>; isBlacklisted: boolean; } interface DataUsageChartProps { usage: SimUsage; remainingQuotaMb: number; isLoading?: boolean; error?: string | null; embedded?: boolean; // when true, render content without card container } export function DataUsageChart({ usage, remainingQuotaMb, isLoading, error, embedded = false }: DataUsageChartProps) { const formatUsage = (usageMb: number) => { if (usageMb >= 1024) { return `${(usageMb / 1024).toFixed(1)} GB`; } return `${usageMb.toFixed(0)} MB`; }; const getUsageColor = (percentage: number) => { if (percentage >= 90) return 'bg-red-500'; if (percentage >= 75) return 'bg-yellow-500'; if (percentage >= 50) return 'bg-orange-500'; return 'bg-green-500'; }; const getUsageTextColor = (percentage: number) => { if (percentage >= 90) return 'text-red-600'; if (percentage >= 75) return 'text-yellow-600'; if (percentage >= 50) return 'text-orange-600'; return 'text-green-600'; }; if (isLoading) { return (
{error}
Current month usage and remaining quota
This SIM is currently blacklisted. Please contact support for assistance.
You've used {usagePercentage.toFixed(1)}% of your data quota. Consider topping up to avoid service interruption.
You've used {usagePercentage.toFixed(1)}% of your data quota. Consider monitoring your usage.