mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
refacto: create src dir & change project indentation to 2 spaces
This commit is contained in:
45
src/components/Links/Links.tsx
Normal file
45
src/components/Links/Links.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user