- Revised README and documentation links to reflect updated paths and improve clarity on service offerings. - Refactored service components to enhance organization and maintainability, including updates to the Internet and SIM offerings. - Improved user navigation and experience in service-related views by streamlining component structures and enhancing data handling. - Updated internal documentation to align with recent changes in service architecture and eligibility processes.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import { useMemo, useState } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
import type { SimCatalogProduct } from "@customer-portal/domain/services";
|
|
import { usePublicSimCatalog } from "@/features/services/hooks";
|
|
import { useServicesBasePath } from "@/features/services/hooks/useServicesBasePath";
|
|
import {
|
|
SimPlansContent,
|
|
type SimPlansTab,
|
|
} from "@/features/services/components/sim/SimPlansContent";
|
|
|
|
/**
|
|
* Public SIM Plans View
|
|
*
|
|
* Displays SIM plans for unauthenticated users.
|
|
* Uses the shared plans UI, with a public navigation handler.
|
|
*/
|
|
export function PublicSimPlansView() {
|
|
const router = useRouter();
|
|
const servicesBasePath = useServicesBasePath();
|
|
const { data, isLoading, error } = usePublicSimCatalog();
|
|
const plans: SimCatalogProduct[] = useMemo(() => data?.plans ?? [], [data?.plans]);
|
|
const [activeTab, setActiveTab] = useState<SimPlansTab>("data-voice");
|
|
|
|
const handleSelectPlan = (planSku: string) => {
|
|
router.push(`${servicesBasePath}/sim/configure?planSku=${encodeURIComponent(planSku)}`);
|
|
};
|
|
|
|
return (
|
|
<SimPlansContent
|
|
variant="public"
|
|
plans={plans}
|
|
isLoading={isLoading}
|
|
error={error}
|
|
activeTab={activeTab}
|
|
onTabChange={setActiveTab}
|
|
onSelectPlan={handleSelectPlan}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default PublicSimPlansView;
|