import { Navigate, useParams } from 'react-router-dom'

/** CI uses `parent/edit_student/(:num)` — canonical SPA uses `parent/students/:id/edit`. */
export function RedirectParentLegacyStudentEdit() {
  const { studentId } = useParams<{ studentId: string }>()
  return <Navigate to={`/app/parent/students/${studentId ?? ''}/edit`} replace />
}

/**
 * CI `parent/edit_emergency_contact/(:num)` and `parent/edit-emergency-contact/(:num)` →
 * SPA `parent/emergency-contact/:contactId`.
 */
export function RedirectParentLegacyEmergencyContactEdit() {
  const { contactId } = useParams<{ contactId: string }>()
  return <Navigate to={`/app/parent/emergency-contact/${contactId ?? ''}`} replace />
}
