import React from 'react'; import Box from '@mui/material/Box'; import type { SxProps, Theme } from '@mui/material/styles'; import { WizardLayout } from '../../templates/WizardLayout'; import { ToggleButtonGroup } from '../../atoms/ToggleButtonGroup'; import { Collapse } from '../../atoms/Collapse'; import { Typography } from '../../atoms/Typography'; import { Button } from '../../atoms/Button'; import { Divider } from '../../atoms/Divider'; // ─── Types ─────────────────────────────────────────────────────────────────── /** Form values for the intro step */ export interface IntroStepValues { /** Who the funeral is being arranged for */ forWhom: 'myself' | 'someone' | null; /** Whether the person has passed away (only relevant when forWhom="someone") */ hasPassedAway: 'yes' | 'no' | null; } /** Field-level error messages */ export interface IntroStepErrors { /** Error for the forWhom field */ forWhom?: string; /** Error for the hasPassedAway field */ hasPassedAway?: string; } /** Props for the IntroStep page component */ export interface IntroStepProps { /** Current form values */ values: IntroStepValues; /** Callback when any field value changes */ onChange: (values: IntroStepValues) => void; /** Callback when the Continue button is clicked */ onContinue: () => void; /** Field-level validation errors */ errors?: IntroStepErrors; /** Whether the Continue button is in a loading state */ loading?: boolean; /** Navigation bar — passed through to WizardLayout */ navigation?: React.ReactNode; /** Hide the help bar */ hideHelpBar?: boolean; /** MUI sx prop for the root */ sx?: SxProps; } // ─── Constants ────────────────────────────────────────────────────────────── const SUBHEADING = "We'll guide you through arranging a funeral, step by step. You can save your progress and come back anytime."; // ─── Component ─────────────────────────────────────────────────────────────── /** * Step 1 — Intro page for the FA arrangement wizard. * * Entry point with urgency-sensitive segmentation. User selects who * the funeral is for, and (if arranging for someone else) whether * that person has passed away. * * Uses the Centered Form layout variant. Progressive disclosure: * selecting "Someone else" reveals the hasPassedAway question. * Selecting "Myself" auto-sets hasPassedAway to "no" (pre-planning). * * Pure presentation component — props in, callbacks out. * No routing, state management, or API calls. * * Spec: documentation/steps/steps/01_intro.yaml */ export const IntroStep: React.FC = ({ values, onChange, onContinue, errors, loading = false, navigation, hideHelpBar, sx, }) => { const handleForWhomChange = (newValue: string | null) => { const forWhom = newValue as IntroStepValues['forWhom']; if (forWhom === 'myself') { // Auto-set hasPassedAway to 'no' — user is alive, pre-planning onChange({ forWhom, hasPassedAway: 'no' }); } else { // Reset hasPassedAway when switching to "someone" onChange({ forWhom, hasPassedAway: null }); } }; const handleHasPassedAwayChange = (newValue: string | null) => { onChange({ ...values, hasPassedAway: newValue as IntroStepValues['hasPassedAway'] }); }; const showHasPassedAway = values.forWhom === 'someone'; return ( {/* Page heading — receives focus on entry for screen readers */} Let's get started {SUBHEADING} { e.preventDefault(); if (!loading) onContinue(); }} > {/* forWhom field */} {/* hasPassedAway field — revealed when forWhom="someone" */} {/* CTA */} ); }; IntroStep.displayName = 'IntroStep'; export default IntroStep;