import type { ReactIsland } from "@ethicdevs/react-monolith";
import React from "react";
import { Organization, Repository } from "@prisma/client";
import type { WithThemeSchemeProp } from "../types";
import { Card } from "../components/Card.styled";
import { Grid } from "../components/Grid";
export interface RepositoriesListProps {
repositories: Array<Repository & { parentOrg: Organization }>;
}
const RepositoriesList: ReactIsland<
RepositoriesListProps & WithThemeSchemeProp
> = ({ repositories, themeScheme }) => {
return (
<>
{repositories.map((repo, idx) => (
<Card
key={repo.id}
themeScheme={themeScheme}
style={{ marginTop: idx >= 1 ? 16 : 32 }}
>
<Grid.Row fluid nowrap>
<h1 style={{ margin: 0, flex: 1 }}>
<a href={`/${repo.parentOrg.slug}/${repo.slug}`}>
{repo.parentOrg.displayName || repo.parentOrg.slug}
{" / "}
{repo.displayName || repo.slug}
{" ∙ "}
<span style={{ textTransform: "capitalize" }}>
({repo.visibility.toLowerCase()})
</span>
</a>
</h1>
{repo.isFork && (
<p style={{ margin: 0, marginTop: 8 }}>
<code>[fork]</code>
</p>
)}
</Grid.Row>
<div>
<p style={{ margin: 0, marginTop: 8 }}>{repo.shortDescription}</p>
{repo.lastPushedAt != null && (
<p style={{ margin: 0, marginTop: 8 }}>
Last push: {new Date(repo.lastPushedAt).toLocaleString()}
</p>
)}
</div>
</Card>
))}
</>
);
};
RepositoriesList.displayName = "RepositoriesList";
export default RepositoriesList;