Unsubscribe confirmations (and any stale links) used the path form which had no route and fell to the SPA not-found screen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
15 lines
662 B
TypeScript
15 lines
662 B
TypeScript
import { createFileRoute, redirect } from "@tanstack/react-router";
|
|
import { SETTINGS_TABS, type SettingsTab } from "../settings";
|
|
|
|
// Path-style deep links (e.g. /dashboard/settings/notifications from e-mail
|
|
// unsubscribe confirmations) — the settings page keys tabs off `?tab=`, so
|
|
// redirect there. Unknown segments fall back to the default tab.
|
|
export const Route = createFileRoute("/dashboard/settings_/$tab")({
|
|
beforeLoad: ({ params }) => {
|
|
const tab = SETTINGS_TABS.includes(params.tab as SettingsTab)
|
|
? (params.tab as SettingsTab)
|
|
: undefined;
|
|
throw redirect({ to: "/dashboard/settings", search: tab ? { tab } : {} });
|
|
},
|
|
});
|