William Nemenchaimprove app
5c6496d (parent 48b426e)4/10/2024, 1:10:30 AM
.ts
TypeScript
(application/typescript)
// 1st-party
import type { ReactView } from "@ethicdevs/react-monolith";
// 3rd-party
import React from "react";
// generated via script[generate:prisma]
import type { Organization } from "@prisma/client";
// app
import type { CommonProps } from "../../types";
import { AppRoute } from "../../routes.defs";
import { Layout, PageWrapper } from "../../components";
import { buildRouteLink } from "../../utils/shared";
// app islands
import RepositoryCreateForm from "../../islands/RepositoryCreateForm";

export interface RepositoryCreateViewProps extends CommonProps {
  availableParentOrgs: Organization[];
  errorMessage?: null | string;
  initialValues?: {
    parent_org_slug?: string;
    repo_slug?: string;
    repo_display_name?: string;
    repo_short_description?: string;
    repo_website_url?: string;
    repo_keywords?: string[];
  };
}

const RepositoryCreateView: ReactView<RepositoryCreateViewProps> = ({
  availableParentOrgs,
  commonProps,
  errorMessage = undefined,
  initialValues = undefined,
}) => {
  return (
    <Layout {...commonProps}>
      <PageWrapper>
        <h1>Create a Repository</h1>
        <div style={{ height: 32 }} />
        {errorMessage && (
          <div className={"error_message"}>
            <p>{errorMessage}</p>
          </div>
        )}
        <form
          action={buildRouteLink(AppRoute.REPOSITORY_CREATE_ACTION, {})}
          method={"POST"}
        >
          <div data-islandid={`${RepositoryCreateForm.name}$$0`}>
            <RepositoryCreateForm
              initialValues={initialValues}
              availableParentOrgs={availableParentOrgs}
              themeScheme={commonProps.themeScheme}
            />
          </div>
        </form>
      </PageWrapper>
    </Layout>
  );
};

RepositoryCreateView.displayName = "RepositoryCreateView";
export default RepositoryCreateView;