From 67bad7819a0000f928831c72fc978a09457423f6 Mon Sep 17 00:00:00 2001 From: barsa Date: Wed, 22 Oct 2025 14:58:54 +0900 Subject: [PATCH] Refactor InstallationOptions component to simplify logic and improve accessibility - Removed unused functions for cleaning up the codebase. - Updated installation description handling for better clarity and user experience. - Enhanced button accessibility with aria-pressed attribute and improved styling. - Streamlined price display logic for clearer presentation of payment options. --- .../internet/InstallationOptions.tsx | 97 +++++++------------ 1 file changed, 35 insertions(+), 62 deletions(-) diff --git a/apps/portal/src/features/catalog/components/internet/InstallationOptions.tsx b/apps/portal/src/features/catalog/components/internet/InstallationOptions.tsx index 97312b8d..03db2be1 100644 --- a/apps/portal/src/features/catalog/components/internet/InstallationOptions.tsx +++ b/apps/portal/src/features/catalog/components/internet/InstallationOptions.tsx @@ -14,40 +14,6 @@ interface InstallationOptionsProps { showSkus?: boolean; } -function getCleanName( - installation: InternetInstallationCatalogItem, - installationTerm: InstallationTerm | null -): string { - const baseName = installation.name.replace(/^(NTT\s*)?Installation\s*Fee\s*/i, ""); - switch (installationTerm) { - case "One-time": - return "Installation Fee (Single Payment)"; - case "12-Month": - return "Installation Fee (12-Month Plan)"; - case "24-Month": - return "Installation Fee (24-Month Plan)"; - default: - return baseName || installation.name; - } -} - -function getCleanDescription( - installationTerm: InstallationTerm | null, - description: string | undefined -): string { - const baseDescription = (description || "").replace(/^(NTT\s*)?Installation\s*Fee\s*/i, ""); - switch (installationTerm) { - case "One-time": - return "Pay the full installation fee upfront."; - case "12-Month": - return "Spread installation cost over 12 monthly payments."; - case "24-Month": - return "Spread installation cost over 24 monthly payments."; - default: - return baseDescription || "Select this installation option."; - } -} - function getPriceLabel(installation: InternetInstallationCatalogItem): string { const priceInfo = getDisplayPrice(installation); if (!priceInfo) { @@ -87,54 +53,61 @@ export function InstallationOptions({ return (
{sortedInstallations.map(installation => { - const installationTerm = installation.catalogMetadata?.installationTerm ?? null; const isSelected = selectedInstallationSku === installation.sku; const priceInfo = getDisplayPrice(installation); + const installationTerm = installation.catalogMetadata?.installationTerm ?? null; + const description = + installation.description || + (installationTerm === "12-Month" + ? "Spread the installation fee across 12 payments." + : installationTerm === "24-Month" + ? "Spread the installation fee across 24 payments." + : "Pay the full installation fee once."); return (