import-offer.tsx
This file
Path
apps/web/src/features/import/import-offer.tsx
49 lines · 1.2 KiB · TypeScript
Last changed by
Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import { isSourceNamespace, ownerOf, ProjectName, shortNameOf,} from "@repo/protocol/ids";import { Option, Schema } from "effect";
import { Workspace } from "../shared/shell/workspace.tsx";import { ImportForm } from "./import-form.tsx";import type { Importer } from "./import-form.tsx";import { sourceUrlOf } from "./prefill.ts";
const decodeProject = Schema.decodeUnknownOption(ProjectName);
export const offerFor = (name: string): Option.Option<ProjectName> => Option.filter(decodeProject(name), (project) => isSourceNamespace(ownerOf(project)) );
export const ImportOffer = ({ importer, project,}: { readonly project: ProjectName; readonly importer: Importer;}) => { const owner = ownerOf(project); const fixedOwner = isSourceNamespace(owner) ? owner : undefined;
return ( <Workspace crumbs={[{ label: project }]} meta={`Nobody has imported ${project} yet. Import it, and you become its maintainer.`} title="Not imported yet" > <ImportForm {...importer} fixedOwner={fixedOwner} here={`/${project}`} prefill={{ name: shortNameOf(project), owner: fixedOwner, url: sourceUrlOf(project), }} /> </Workspace> );};