refacto: create src dir & change project indentation to 2 spaces

This commit is contained in:
Sonny
2023-04-24 23:53:32 +02:00
parent acce5666e5
commit 426f2a52df
88 changed files with 1472 additions and 1490 deletions

View File

@@ -0,0 +1,45 @@
import LinkTag from "next/link";
import { Category } from "types";
import LinkItem from "./LinkItem";
import styles from "./links.module.scss";
export default function Links({ category }: { category: Category }) {
if (category === null) {
return (
<div className={styles["no-category"]}>
<p>Veuillez séléctionner une categorié</p>
<LinkTag href="/category/create">ou en créer une</LinkTag>
</div>
);
}
const { name, links } = category;
if (links.length === 0) {
return (
<div className={styles["no-link"]}>
<p>
Aucun lien pour <b>{category.name}</b>
</p>
<LinkTag href={`/link/create?categoryId=${category.id}`}>
Créer un lien
</LinkTag>
</div>
);
}
return (
<div className={styles["links-wrapper"]}>
<h2>
{name}
<span className={styles["links-count"]}> {links.length}</span>
</h2>
<ul className={styles["links"]} key={Math.random()}>
{links.map((link, key) => (
<LinkItem key={key} link={link} />
))}
</ul>
</div>
);
}