'use client' import { useEffect, useId, useMemo, useRef, type ReactNode } from 'react' import { CampaignListResults } from '@/components/campaign/shared/CampaignListPending' import { toCampaignWizardChromeState, useSetCampaignWizardChrome, type CampaignWizardChromeSkip, } from '@/components/campaign/shell/CampaignWizardChromeContext' import { CAMPAIGN_HOME } from '@/lib/campaignPaths' import { WIZARD_STEP_PENDING_MESSAGE } from '@/lib/campaignWizardCopy' import { cn } from '@/lib/utils' export type CampaignWizardShellProps = { flowTitle: string stepTitle: string isEntryStep: boolean previousHref: string dismissHref?: string municipalityLabel?: string skip?: CampaignWizardChromeSkip trailingAction?: ReactNode contentAlign?: 'start' | 'end' children: ReactNode } export const CampaignWizardShell = ({ flowTitle, stepTitle, isEntryStep, previousHref, dismissHref = CAMPAIGN_HOME, municipalityLabel, skip, trailingAction, contentAlign = 'start', children, }: CampaignWizardShellProps) => { const titleRef = useRef(null) const titleId = useId() const chrome = useMemo( () => toCampaignWizardChromeState({ flowTitle, isEntryStep, previousHref, dismissHref, municipalityLabel, skip, }), [dismissHref, flowTitle, isEntryStep, municipalityLabel, previousHref, skip], ) useSetCampaignWizardChrome(chrome) useEffect(() => { titleRef.current?.focus() }, [stepTitle]) return (
{trailingAction ?
{trailingAction}
: null}
{municipalityLabel ? (

{municipalityLabel}

) : null}

{stepTitle}

{children}
) }