import { Link, useLocation } from 'react-router-dom' import { BrandSwitcher } from './BrandSwitcher' import { TopicSwitcher } from './TopicSwitcher' import { PLACEMENT_FLOW, detectPlacementFlowStep, placementFlowPath, type PlacementFlowStepKey, } from '../lib/placementFlow' import type { BrandData } from '../types/brand' import type { PlacementTopicData } from '../types/placementTopic' type TopicNavProps = { topicId: string topics: PlacementTopicData[] onTopicChange: (id: string) => void topicLoading?: boolean brandId?: never brands?: never onBrandChange?: never brandLoading?: never } type BrandNavProps = { brandId: string brands: BrandData[] onBrandChange: (id: string) => void brandLoading?: boolean topicId?: never topics?: never onTopicChange?: never topicLoading?: never } type Props = (TopicNavProps | BrandNavProps) & { active?: PlacementFlowStepKey } export function PlacementFlowNav(props: Props) { const { active } = props const { pathname } = useLocation() const current = active ?? detectPlacementFlowStep(pathname) ?? 'research' const topicMode = 'topics' in props && props.topics !== undefined const flowId = topicMode ? props.topicId : props.brandId const flowScope = topicMode ? 'topic' : 'brand' return ( ) }