mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
feat: show category header even without link
This commit is contained in:
@@ -25,34 +25,36 @@ export default function Links({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { id, name, links } = category;
|
const { id, name, links } = category;
|
||||||
if (links.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className={styles["no-link"]}>
|
|
||||||
<p>
|
|
||||||
Aucun lien pour <b>{name}</b>
|
|
||||||
</p>
|
|
||||||
<LinkTag href={`/link/create?categoryId=${id}`}>Créer un lien</LinkTag>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["links-wrapper"]}>
|
<div className={styles["links-wrapper"]}>
|
||||||
<h2 className={styles["category-header"]}>
|
<h2 className={styles["category-header"]}>
|
||||||
<span className={styles["category-name"]}>
|
<span className={styles["category-name"]}>
|
||||||
{name}
|
{name}
|
||||||
|
{links.length > 0 && (
|
||||||
<span className={styles["links-count"]}> — {links.length}</span>
|
<span className={styles["links-count"]}> — {links.length}</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
<span className={styles["category-controls"]}>
|
<span className={styles["category-controls"]}>
|
||||||
<EditItem type="category" id={id} />
|
<EditItem type="category" id={id} />
|
||||||
<RemoveItem type="category" id={id} />
|
<RemoveItem type="category" id={id} />
|
||||||
</span>
|
</span>
|
||||||
</h2>
|
</h2>
|
||||||
|
{links.length !== 0 ? (
|
||||||
<ul className={styles["links"]} key={Math.random()}>
|
<ul className={styles["links"]} key={Math.random()}>
|
||||||
{links.map((link, key) => (
|
{links.map((link, key) => (
|
||||||
<LinkItem key={key} link={link} toggleFavorite={toggleFavorite} />
|
<LinkItem key={key} link={link} toggleFavorite={toggleFavorite} />
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
) : (
|
||||||
|
<div className={styles["no-link"]}>
|
||||||
|
<p>
|
||||||
|
Aucun lien pour <b>{name}</b>
|
||||||
|
</p>
|
||||||
|
<LinkTag href={`/link/create?categoryId=${id}`}>
|
||||||
|
Créer un lien
|
||||||
|
</LinkTag>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user