import { Card } from "@/components/ui/card"; import { FuelIcon } from "@/components/ui/phosphor-icons"; export interface FuelPriceData { region: string; pertalite: number | null; pertamax: number | null; pertamaxGreen: number | null; pertamaxTurbo: number | null; pertamaxPertashop: number | null; pertaminaDex: number | null; dexlite: number | null; bioSolarNonSubsidi: number | null; bioSolarSubsidi: number | null; } export interface FuelPricesResponse { succeeded: boolean; lastUpdated: string; gasoline: FuelPriceData[]; diesel: FuelPriceData[]; } interface GasStationStatsCardsProps { fuelPrices: FuelPricesResponse | null; loading: boolean; } export function GasStationStatsCards({ fuelPrices, loading }: GasStationStatsCardsProps) { // Find Kalimantan Barat prices const kalbarGas = fuelPrices?.gasoline?.find( (g) => g.region === "Prov. Kalimantan Barat" ); const kalbarDiesel = fuelPrices?.diesel?.find( (d) => d.region === "Prov. Kalimantan Barat" ); const formatPrice = (p: number | null | undefined) => { if (loading) return "Loading..."; if (p == null) return "Rp —"; return "Rp " + p.toLocaleString("id-ID"); }; const lastUpdatedText = fuelPrices?.lastUpdated || "Update terbaru"; return ( <> {/* Card 1: Pertalite */}
Pertalite (RON 90)
{formatPrice(kalbarGas?.pertalite)}
Prov. Kalimantan Barat {lastUpdatedText}
{/* Card 2: Pertamax */}
Pertamax (RON 92)
{formatPrice(kalbarGas?.pertamax)}
Prov. Kalimantan Barat {lastUpdatedText}
{/* Card 3: Dexlite */}
Dexlite (Diesel)
{formatPrice(kalbarDiesel?.dexlite)}
Prov. Kalimantan Barat {lastUpdatedText}
{/* Card 4: Bio Solar (Subsidi) */}
Bio Solar (Subsidi)
{formatPrice(kalbarDiesel?.bioSolarSubsidi)}
Prov. Kalimantan Barat {lastUpdatedText}
); }