import { Navigate, useLocation } from "react-router-dom"

/**
 * Back-compat for `/settings` and legacy hash links.
 *
 * Sidebar **Settings** → org-level (Add product / branding).
 * Personal display preferences live under **Profile → Settings**
 * (`/settings/profile`).
 */
export default function SettingsLegacyRedirect() {
  const location = useLocation()
  const hash = location.hash.replace(/^#/, "").toLowerCase()

  if (hash === "appearance" || hash === "profile" || hash === "tours" || hash === "input-formats") {
    return <Navigate to="/settings/profile" replace />
  }

  return <Navigate to="/settings/organization" replace />
}
