import React from 'react'; import Box from '@mui/material/Box'; import type { SxProps, Theme } from '@mui/material/styles'; import { Typography } from '../../atoms/Typography'; import { Button } from '../../atoms/Button'; import { ServiceOption } from '../../molecules/ServiceOption'; // ─── Types ─────────────────────────────────────────────────────────────────── /** A service option within the selector */ export interface ServiceItem { /** Unique identifier */ id: string; /** Option name */ name: string; /** Price in dollars */ price?: number; /** Description text */ description?: string; /** Whether this option is unavailable */ disabled?: boolean; } /** Props for the FA ServiceSelector organism */ export interface ServiceSelectorProps { /** Section heading (e.g. "Choose a service type") */ heading: string; /** Optional subheading providing context */ subheading?: string; /** Available options */ items: ServiceItem[]; /** Currently selected item ID */ selectedId?: string; /** Called when the user selects an option */ onSelect?: (id: string) => void; /** Label for the continue/next button — omit to hide */ continueLabel?: string; /** Called when the user clicks continue */ onContinue?: () => void; /** Whether continue is disabled (e.g. nothing selected) — defaults to requiring selection */ continueDisabled?: boolean; /** Max visible description lines before "View more" toggle */ maxDescriptionLines?: number; /** MUI sx prop for the root element */ sx?: SxProps; } // ─── Component ─────────────────────────────────────────────────────────────── /** * Service selection panel for the FA arrangement flow. * * Presents a heading, subheading, and a list of ServiceOption cards * for single-select (radio) behaviour. An optional continue button * advances to the next step. * * Composes Typography + ServiceOption + Button. * * Usage: * ```tsx * nextStep()} * /> * ``` */ export const ServiceSelector = React.forwardRef( ( { heading, subheading, items, selectedId, onSelect, continueLabel, onContinue, continueDisabled, maxDescriptionLines, sx, }, ref, ) => { const nothingSelected = !selectedId; const isContinueDisabled = continueDisabled ?? nothingSelected; return ( {/* Header */} {heading} {subheading && ( {subheading} )} {/* Options list */} {items.map((item) => ( onSelect?.(item.id)} maxDescriptionLines={maxDescriptionLines} /> ))} {/* Continue button */} {continueLabel && ( )} ); }, ); ServiceSelector.displayName = 'ServiceSelector'; export default ServiceSelector;