"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import { PageLayout } from "@/components/templates/PageLayout"; import { SubCard } from "@/components/molecules/SubCard/SubCard"; import { DevicePhoneMobileIcon, DeviceTabletIcon, CpuChipIcon } from "@heroicons/react/24/outline"; import { simActionsService, type ReissueSimRequest, } from "@/features/subscriptions/services/sim-actions.service"; import { AlertBanner } from "@/components/molecules/AlertBanner/AlertBanner"; import type { SimDetails } from "@/features/sim-management/components/SimDetailsCard"; import { Button } from "@/components/atoms"; type SimType = "physical" | "esim"; export function SimReissueContainer() { const params = useParams(); const subscriptionId = params.id as string; const [simType, setSimType] = useState(null); const [newEid, setNewEid] = useState(""); const [currentEid, setCurrentEid] = useState(null); const [simDetails, setSimDetails] = useState(null); const [message, setMessage] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const [loadingDetails, setLoadingDetails] = useState(true); useEffect(() => { const fetchDetails = async () => { try { const info = await simActionsService.getSimInfo(subscriptionId); if (info?.details) { setSimDetails(info.details); setCurrentEid(info.details.eid || null); } } catch (e: unknown) { setError( process.env.NODE_ENV === "development" ? e instanceof Error ? e.message : "Failed to load SIM details" : "Unable to load SIM details right now. Please try again." ); } finally { setLoadingDetails(false); } }; void fetchDetails(); }, [subscriptionId]); const isValidEid = () => { return /^\d{32}$/.test(newEid.trim()); }; const submit = async (e: React.FormEvent) => { e.preventDefault(); if (!simType) { setError("Please select a SIM type"); return; } if (simType === "esim" && !isValidEid()) { setError("Please enter a valid 32-digit EID"); return; } setLoading(true); setMessage(null); setError(null); try { const request: ReissueSimRequest = { simType, ...(simType === "esim" && { newEid: newEid.trim() }), }; await simActionsService.reissueSim(subscriptionId, request); if (simType === "esim") { setMessage( "eSIM reissue request submitted successfully. You will receive instructions via email to download your new eSIM profile." ); } else { setMessage( "Physical SIM reissue request submitted successfully. You will be contacted shortly with shipping details (typically 3-5 business days)." ); } } catch (e: unknown) { setError( process.env.NODE_ENV === "development" ? e instanceof Error ? e.message : "Failed to submit reissue request" : "Unable to submit your request right now. Please try again." ); } finally { setLoading(false); } }; return ( } title="Reissue SIM" description="Request a replacement SIM card" >
← Back to SIM Management

Request SIM Reissue

If your SIM card is lost, damaged, or you need to switch between physical SIM and eSIM, you can request a replacement here.

{message && (
{message}
)} {error && (
{error}
)} {loadingDetails ? (
) : (
void submit(e)} className="space-y-6"> {/* Current SIM Info */} {simDetails && (
Current SIM
Number:{" "} {simDetails.msisdn}
Type:{" "} {simDetails.simType}
{simDetails.iccid && (
ICCID:{" "} {simDetails.iccid}
)} {currentEid && (
Current EID:{" "} {currentEid}
)}
)} {/* SIM Type Selection */}
{/* Physical SIM Option */} {/* eSIM Option */}
{/* eSIM EID Input */} {simType === "esim" && (
setNewEid(e.target.value.replace(/\D/g, ""))} placeholder="Enter your device's 32-digit EID" maxLength={32} className="w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-ring font-mono bg-background text-foreground" />

The EID is a 32-digit number unique to your device. You can find it in your device settings under "About" or "SIM status".

{newEid && !isValidEid() && (

Please enter exactly 32 digits ({newEid.length}/32)

)}
{currentEid && (
Current EID:{" "} {currentEid}
)}
)} {/* Physical SIM Info */} {simType === "physical" && (

Physical SIM Information

  • • A new physical SIM card will be shipped to your registered address
  • • Typical delivery time: 3-5 business days
  • • You will receive an email with tracking information
  • • The old SIM card will be deactivated once the new one is activated
)} {/* Submit Buttons */}
)}
); } export default SimReissueContainer;