import { Navigate, useLocation } from 'react-router-dom'
import { topicIdFromSearch } from '../lib/placementFlow'
import { PersonaOutreachPage } from '../pages/PersonaOutreachPage'

/** /outreach 為找 TA 子步驟（留言工作台），需 ?topic=；否則導向找 TA 主題列表 */
export function OutreachEntryRoute() {
  const { search } = useLocation()
  const topicId = topicIdFromSearch(search)
  if (!topicId) {
    return <Navigate to="/placement/topics" replace />
  }
  return <PersonaOutreachPage />
}