2025-12-17 14:07:22 +09:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { useMemo, useState } from "react";
|
2025-12-25 15:48:57 +09:00
|
|
|
import { useRouter } from "next/navigation";
|
2025-12-25 13:20:45 +09:00
|
|
|
import type { SimCatalogProduct } from "@customer-portal/domain/services";
|
2025-12-25 15:48:57 +09:00
|
|
|
import { usePublicSimCatalog } from "@/features/services/hooks";
|
2025-12-25 13:20:45 +09:00
|
|
|
import { useServicesBasePath } from "@/features/services/hooks/useServicesBasePath";
|
2025-12-24 19:01:21 +09:00
|
|
|
import {
|
2025-12-25 15:48:57 +09:00
|
|
|
SimPlansContent,
|
|
|
|
|
type SimPlansTab,
|
|
|
|
|
} from "@/features/services/components/sim/SimPlansContent";
|
2025-12-24 19:01:21 +09:00
|
|
|
|
2025-12-17 14:07:22 +09:00
|
|
|
/**
|
|
|
|
|
* Public SIM Plans View
|
|
|
|
|
*
|
|
|
|
|
* Displays SIM plans for unauthenticated users.
|
2025-12-25 15:48:57 +09:00
|
|
|
* Uses the shared plans UI, with a public navigation handler.
|
2025-12-17 14:07:22 +09:00
|
|
|
*/
|
|
|
|
|
export function PublicSimPlansView() {
|
2025-12-25 15:48:57 +09:00
|
|
|
const router = useRouter();
|
2025-12-24 19:01:21 +09:00
|
|
|
const servicesBasePath = useServicesBasePath();
|
2025-12-25 15:48:57 +09:00
|
|
|
const { data, isLoading, error } = usePublicSimCatalog();
|
|
|
|
|
const plans: SimCatalogProduct[] = useMemo(() => data?.plans ?? [], [data?.plans]);
|
|
|
|
|
const [activeTab, setActiveTab] = useState<SimPlansTab>("data-voice");
|
2025-12-24 19:01:21 +09:00
|
|
|
|
|
|
|
|
const handleSelectPlan = (planSku: string) => {
|
2025-12-25 15:48:57 +09:00
|
|
|
router.push(`${servicesBasePath}/sim/configure?planSku=${encodeURIComponent(planSku)}`);
|
2025-12-18 18:12:20 +09:00
|
|
|
};
|
2025-12-17 14:07:22 +09:00
|
|
|
|
|
|
|
|
return (
|
2025-12-25 15:48:57 +09:00
|
|
|
<SimPlansContent
|
|
|
|
|
variant="public"
|
|
|
|
|
plans={plans}
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
error={error}
|
|
|
|
|
activeTab={activeTab}
|
|
|
|
|
onTabChange={setActiveTab}
|
|
|
|
|
onSelectPlan={handleSelectPlan}
|
|
|
|
|
/>
|
2025-12-17 14:07:22 +09:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PublicSimPlansView;
|