"use client"; import React from "react"; import { formatPlanShort } from "@/lib/utils"; import { DevicePhoneMobileIcon, CheckCircleIcon, ExclamationTriangleIcon, XCircleIcon, ClockIcon, } from "@heroicons/react/24/outline"; import type { SimDetails, SimStatus } from "@customer-portal/domain/sim"; interface SimDetailsCardProps { simDetails: SimDetails; isLoading?: boolean; error?: string | null; embedded?: boolean; showFeaturesSummary?: boolean; } const STATUS_ICON_MAP: Record = { active: , suspended: , cancelled: , pending: , }; const STATUS_BADGE_CLASS_MAP: Record = { active: "bg-green-100 text-green-800", suspended: "bg-yellow-100 text-yellow-800", cancelled: "bg-red-100 text-red-800", pending: "bg-blue-100 text-blue-800", }; const formatDate = (value?: string | null) => { if (!value) return "-"; const date = new Date(value); return Number.isNaN(date.getTime()) ? value : date.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }); }; const formatQuota = (remainingMb: number) => { if (remainingMb >= 1000) { return `${(remainingMb / 1000).toFixed(1)} GB`; } return `${remainingMb.toFixed(0)} MB`; }; const FeatureToggleRow = ({ label, enabled }: { label: string; enabled: boolean }) => (
{label} {enabled ? "Enabled" : "Disabled"}
); const LoadingCard = ({ embedded }: { embedded: boolean }) => (
); const ErrorCard = ({ embedded, message }: { embedded: boolean; message: string }) => (
{message}
); export function SimDetailsCard({ simDetails, isLoading = false, error = null, embedded = false, showFeaturesSummary = true, }: SimDetailsCardProps) { if (isLoading) { return ; } if (error) { return ; } const planName = simDetails.planName || formatPlanShort(simDetails.planCode) || "SIM Plan"; const statusIcon = STATUS_ICON_MAP[simDetails.status] ?? ( ); const statusClass = STATUS_BADGE_CLASS_MAP[simDetails.status] ?? "bg-gray-100 text-gray-800"; const containerClasses = embedded ? "" : "bg-white shadow-lg rounded-xl border border-gray-100"; return (

{planName}

Account #{simDetails.account}

{statusIcon} {simDetails.status}

SIM Information

Phone Number
{simDetails.msisdn}
SIM Type
{simDetails.simType}
ICCID
{simDetails.iccid}
{simDetails.eid && (
EID
{simDetails.eid}
)}
Network Type
{simDetails.networkType}

Data Remaining

{formatQuota(simDetails.remainingQuotaMb)}

Remaining allowance in current cycle

Activation Timeline

Activated
{formatDate(simDetails.activatedAt)}
Expires
{formatDate(simDetails.expiresAt)}
{showFeaturesSummary && (

Service Features

)}
); } export type { SimDetails };