import React from 'react'; import Box from '@mui/material/Box'; import type { SxProps, Theme } from '@mui/material/styles'; import { WizardLayout } from '../../templates/WizardLayout'; import { ProviderCardCompact } from '../../molecules/ProviderCardCompact'; import { ServiceOption } from '../../molecules/ServiceOption'; import { PackageDetail } from '../../organisms/PackageDetail'; import type { PackageSection } from '../../organisms/PackageDetail'; import { Typography } from '../../atoms/Typography'; import { Divider } from '../../atoms/Divider'; // ─── Types ─────────────────────────────────────────────────────────────────── /** Provider summary for the compact card */ export interface PackagesStepProvider { /** Provider name */ name: string; /** Location */ location: string; /** Image URL */ imageUrl?: string; /** Rating */ rating?: number; /** Review count */ reviewCount?: number; } /** Package data for the selection list */ export interface PackageData { /** Unique package ID */ id: string; /** Package display name */ name: string; /** Package price in dollars */ price: number; /** Short description */ description?: string; /** Line item sections for the detail panel */ sections: PackageSection[]; /** Total price (may differ from base price with extras) */ total?: number; /** Extra items section (after total) */ extras?: PackageSection; /** Terms and conditions */ terms?: string; } /** Props for the PackagesStep page component */ export interface PackagesStepProps { /** Provider summary shown at top of the list panel */ provider: PackagesStepProvider; /** Packages matching the user's filters from the previous step */ packages: PackageData[]; /** Other packages from this provider that didn't match filters (shown in secondary group) */ otherPackages?: PackageData[]; /** Currently selected package ID */ selectedPackageId: string | null; /** Callback when a package is selected */ onSelectPackage: (id: string) => void; /** Callback when "Make Arrangement" is clicked (opens ArrangementDialog) */ onArrange: () => void; /** Callback when the provider card is clicked (opens provider profile popup) */ onProviderClick?: () => void; /** Callback for the Back button */ onBack: () => void; /** Validation error */ error?: string; /** Whether the arrange action is loading */ loading?: boolean; /** Navigation bar */ navigation?: React.ReactNode; /** Whether this is a pre-planning flow */ isPrePlanning?: boolean; /** MUI sx prop */ sx?: SxProps; } // ─── Component ─────────────────────────────────────────────────────────────── /** * Step 3 — Package selection page for the FA arrangement wizard. * * List + Detail split layout. Left panel shows the selected provider * (compact) and selectable package cards. Right panel shows the full * detail breakdown of the selected package with "Make Arrangement" CTA. * * Packages are split into two groups: * - **Matching your preferences**: packages that matched the user's filters * from the providers step * - **Other packages from [Provider]**: remaining packages outside those * filters, shown below a divider for passive discovery * * Selecting a package reveals its detail. Clicking "Make Arrangement" * on the detail panel triggers the ArrangementDialog (D-E). * * Pure presentation component — props in, callbacks out. * * Spec: documentation/steps/steps/03_packages.yaml */ export const PackagesStep: React.FC = ({ provider, packages, otherPackages = [], selectedPackageId, onSelectPackage, onArrange, onProviderClick, onBack, error, loading = false, navigation, isPrePlanning = false, sx, }) => { const allPackages = [...packages, ...otherPackages]; const selectedPackage = allPackages.find((p) => p.id === selectedPackageId); const hasOtherPackages = otherPackages.length > 0; const subheading = isPrePlanning ? 'Compare packages to find what suits your wishes. Nothing is committed until you confirm.' : 'Each package includes a set of services. You can customise your selections in the next steps.'; return ( ) : ( Select a package to see what's included. ) } > {/* Provider compact card — clickable to open provider profile */} {/* Heading */} Choose a funeral package {subheading} {/* Error message */} {error && ( {error} )} {/* ─── Matching packages ─── */} {hasOtherPackages && ( Matching your preferences )} {packages.map((pkg) => ( onSelectPackage(pkg.id)} /> ))} {packages.length === 0 && ( No packages match your current preferences. )} {/* ─── Other packages (passive discovery) ─── */} {hasOtherPackages && ( <> Other packages from {provider.name} {otherPackages.map((pkg) => ( onSelectPackage(pkg.id)} /> ))} )} ); }; PackagesStep.displayName = 'PackagesStep'; export default PackagesStep;