import type { ReactView } from "@ethicdevs/react-monolith";
import React from "react";
import type { Organization } from "@prisma/client";
import type { CommonProps } from "../../types";
import { AppRoute } from "../../routes.defs";
import { Layout, PageWrapper } from "../../components";
import { buildRouteLink } from "../../utils/shared";
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;