From a3a4c50f26b8750ae1c87f1f1103b84b7d2e6315 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 14 Nov 2023 15:11:22 +0100
Subject: refactor(components): replace LinksListWidget with LinksWidget

* avoid List component repeat
* rewrite tests and CSS
* add an id to LinksWidgetItemData (previously LinksListItems) type
because the label could be duplicated
---
 src/components/organisms/widgets/table-of-contents.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'src/components/organisms/widgets/table-of-contents.tsx')

diff --git a/src/components/organisms/widgets/table-of-contents.tsx b/src/components/organisms/widgets/table-of-contents.tsx
index 8892485..5f14415 100644
--- a/src/components/organisms/widgets/table-of-contents.tsx
+++ b/src/components/organisms/widgets/table-of-contents.tsx
@@ -1,9 +1,9 @@
 import type { FC } from 'react';
 import { useIntl } from 'react-intl';
 import { useHeadingsTree, type Heading } from '../../../utils/hooks';
-import { type LinksListItems, LinksListWidget } from './links-list-widget';
+import { Heading as HeadingComponent } from '../../atoms';
+import { LinksWidget, type LinksWidgetItemData } from './links-widget';
 import styles from './table-of-contents.module.scss';
-import { Heading as HeadingComponent } from 'src/components/atoms';
 
 type TableOfContentsProps = {
   /**
@@ -32,17 +32,18 @@ export const TableOfContents: FC<TableOfContentsProps> = ({ wrapper }) => {
    * @param {Heading[]} tree - The headings tree.
    * @returns {LinksListItems[]} The list items.
    */
-  const getItems = (tree: Heading[]): LinksListItems[] =>
+  const getItems = (tree: Heading[]): LinksWidgetItemData[] =>
     tree.map((heading) => {
       return {
-        name: heading.title,
+        id: heading.id,
+        label: heading.title,
         url: `#${heading.id}`,
         child: getItems(heading.children),
       };
     });
 
   return (
-    <LinksListWidget
+    <LinksWidget
       className={styles.list}
       heading={
         <HeadingComponent isFake level={3}>
-- 
cgit v1.2.3

