Skip to content
Myr

moved.ts

This file

Path

apps/web/src/features/visibility/moved.ts

32 lines · 1.0 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 1–32why, one step back
1import { redirect } from "@tanstack/react-router";
2import { Effect } from "effect";34import {5 ENVIRONMENT_ANCHOR,6 LEDGER_ANCHOR,7 visibilityHref,8} from "../shared/paths.ts";910interface Moving {11 readonly location: { readonly searchStr: string };12 readonly params: { readonly project: string };13}1415// A project's old ledger and env pages folded into the Visibility tab (ADR 0041). The worker answers a document load with16// its own 301 (`canonicalAddress`); this sends on a navigation inside the app, from a page kept before the move.17// It rejects with the redirect: the lint keeps a bare `throw` for `Error`s, which a redirect is not.18const movedFrom =19 (anchor: string) =>20 ({ location, params }: Moving): Promise<never> =>21 Effect.runPromise(22 Effect.fail(23 redirect({24 href: visibilityHref(params.project, anchor, location.searchStr),25 statusCode: 301,26 })27 )28 );2930export const movedToEnvironment = movedFrom(ENVIRONMENT_ANCHOR);3132export const movedToLedger = movedFrom(LEDGER_ANCHOR);