Skip to content

g1t/apps/web/app/routes/workspace/tab-soon.tsx

32 lines1,409 bytesCodeBlame
1import { data } from "react-router";
2
3import type { Route } from "./+types/tab-soon";
4import { page } from "../../lib/meta";
5import { roadmapItem } from "../../lib/roadmap";
6import { getViewer, roleIn } from "../../lib/session.server";
7import { pagePath } from "../../lib/workspace-nav";
8import { SoonView } from "../repo/soon";
9
10/** The page is the last part of the address: `-/insights`. */
11const tabOf = (pathname: string) => pagePath(pathname).split("/").pop() ?? "";
12
13export function meta({ params, ...args }: Route.MetaArgs) {
14 const item = roadmapItem(tabOf(args.location.pathname));
15 return page(args, {
16 title: `${item?.title ?? "Soon"} · ${params.owner} · g1t`,
17 description: item ? `Soon on g1t: ${item.summary}` : null,
18 });
19}
20
21export function loader({ params, context, request }: Route.LoaderArgs) {
22 // For the workspace's members, as its People and Teams are.
23 if (!roleIn(getViewer(context), params.owner)) throw data(null, { status: 404 });
24 const item = roadmapItem(tabOf(new URL(request.url).pathname));
25 if (!item || item.section !== "Workspace") throw data(null, { status: 404 });
26 return { item };
27}
28
29/** A page of the workspace's that is coming: Insights. */
30export default function WorkspaceTabSoon({ loaderData, params }: Route.ComponentProps) {
31 return <SoonView item={loaderData.item} base={`/${params.owner}/-`} newProject={`/new?workspace=${params.owner}`} />;
32}