From 9f9a1897ee244a30461e443ab837090c8491680a Mon Sep 17 00:00:00 2001 From: tema Date: Fri, 21 Nov 2025 18:47:45 +0900 Subject: [PATCH] Refactor SimManagementSection for improved structure and user experience - Consolidated SIM details and actions into a more organized layout, enhancing readability and usability. - Removed unnecessary usage data handling, focusing on essential SIM details. - Updated loading and error states for better user feedback during data fetching. - Introduced new components for SIM actions and feature toggles, streamlining the management interface. --- .../components/SimManagementSection.tsx | 317 +++++++----------- 1 file changed, 114 insertions(+), 203 deletions(-) diff --git a/apps/portal/src/features/sim-management/components/SimManagementSection.tsx b/apps/portal/src/features/sim-management/components/SimManagementSection.tsx index 481e9fc8..d637879b 100644 --- a/apps/portal/src/features/sim-management/components/SimManagementSection.tsx +++ b/apps/portal/src/features/sim-management/components/SimManagementSection.tsx @@ -5,11 +5,11 @@ import { DevicePhoneMobileIcon, ExclamationTriangleIcon, ArrowPathIcon, - DocumentTextIcon, } from "@heroicons/react/24/outline"; -import { type SimDetails } from "./SimDetailsCard"; +import { SimDetailsCard, type SimDetails } from "./SimDetailsCard"; +import { SimActions } from "./SimActions"; import { apiClient } from "@/lib/api"; -import Link from "next/link"; +import { SimFeatureToggles } from "./SimFeatureToggles"; interface SimManagementSectionProps { subscriptionId: number; @@ -17,17 +17,12 @@ interface SimManagementSectionProps { interface SimInfo { details: SimDetails; - usage?: { - todayUsageMb: number; - recentDaysUsage: Array<{ date: string; usageMb: number }>; - }; } export function SimManagementSection({ subscriptionId }: SimManagementSectionProps) { const [simInfo, setSimInfo] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); - const [activeTab, setActiveTab] = useState<"sim" | "invoices">("sim"); const fetchSimInfo = useCallback(async () => { try { @@ -43,7 +38,8 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro throw new Error("Failed to load SIM information"); } - setSimInfo(payload); + // Only use the details part, ignore usage data + setSimInfo({ details: payload.details }); } catch (err: unknown) { const hasStatus = (v: unknown): v is { status: number } => typeof v === "object" && @@ -51,6 +47,7 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro "status" in v && typeof (v as { status: unknown }).status === "number"; if (hasStatus(err) && err.status === 400) { + // Not a SIM subscription - this component shouldn't be shown setError("This subscription is not a SIM service"); } else { setError(err instanceof Error ? err.message : "Failed to load SIM information"); @@ -70,36 +67,31 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro }; const handleActionSuccess = () => { + // Refresh SIM info after any successful action void fetchSimInfo(); }; if (loading) { return ( -
- {/* Header */} -
-
-

Service Management

-
-
- SIM Management -
-
- Invoices -
+
+
+
+
+ +
+
+

SIM Management

+

Loading your SIM service details...

-
- - {/* Loading Animation */} -
-
-
-
-
-
+
+
+
+
+
+
+
-
@@ -108,19 +100,27 @@ export function SimManagementSection({ subscriptionId }: SimManagementSectionPro if (error) { return ( -
-
-

Service Management

+
+
+
+ +
+
+

SIM Management

+

Unable to load SIM information

+
-
+
-

Unable to Load SIM Information

+

+ Unable to Load SIM Information +

{error}

- - Invoices - +
+

+ {simInfo.details.simType === "esim" ? "eSIM" : "Physical SIM"} Service +

+

Subscription ID {subscriptionId}

+ + {simInfo.details.status.charAt(0).toUpperCase() + simInfo.details.status.slice(1)} +
- {/* Content */} -
- {/* 2. Billing Information Section */} -
-
-
-

Monthly Cost

-

¥3,100

+ {/* Two Column Layout */} +
+ {/* Left Column - Main Actions */} +
+ {/* Subscription Details Card */} +
+
+

Subscription Details

-
-

Next Billing

-

Jul 1 2025

-
-
-

Registered

-

Aug 2 2023

-
-
-
- - {/* 3. Invoice & Data Usage Row */} -
- {/* Left Column - Invoice Card */} -
-
-

Latest Invoice

-

3400 ¥

-
- -
- - {/* Right Column - Data Usage Circle */} -
-

Remaining data

-
- - - - -
-

{remainingGB.toFixed(1)} GB

-

–{usedMB.toFixed(2)} GB

+
+
+

Monthly Cost

+

¥3,100

+
+
+

Next Billing

+

Jul 1, 2024

+
+
+

Registration

+

Aug 2, 2023

-
- {/* 4. Top Up Button */} - + {/* SIM Management Actions Card */} +
+
+

SIM Management Actions

+
+ +
- {/* 5. SIM Management Actions Section */} -
-

SIM Management Actions

-
- - - - + {/* Voice Status Card */} +
+
+

Voice Status

+
+
- {/* 6. Voice Status Section */} -
-

Voice Status

-
- - - - + {/* Right Column - SIM Details & Usage */} +
+ {/* SIM Details Card */} +
+
+

SIM Details

+
+
- - {/* 7. Important Notes Section */} -
-

Important Notes

-
    -
  • - - Changes to SIM settings typically take effect instantaneously (approx. 30min) -
  • -
  • - - May require smartphone device restart after changes are applied -
  • -
  • - - Voice/Network/Plan change requests must be requested at least 30 minutes apart -
  • -
  • - - Changes to Voice Mail / Call Waiting must be requested before the 25th of the month -
  • -
-
+
); }