2024-07-29 07:45:59 -07:00
|
|
|
import type { FC } from 'react';
|
|
|
|
|
import { useBookmarkContext } from '~/Providers/BookmarkContext';
|
|
|
|
|
import BookmarkItem from './BookmarkItem';
|
2024-08-08 18:16:17 +02:00
|
|
|
interface BookmarkItemsProps {
|
2024-07-29 07:45:59 -07:00
|
|
|
tags: string[];
|
2024-08-22 17:09:05 -04:00
|
|
|
handleSubmit: (tag?: string) => void;
|
2024-07-29 07:45:59 -07:00
|
|
|
header: React.ReactNode;
|
2024-08-08 18:16:17 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-16 10:30:14 +02:00
|
|
|
const BookmarkItems: FC<BookmarkItemsProps> = ({ tags, handleSubmit, header }) => {
|
2024-07-29 07:45:59 -07:00
|
|
|
const { bookmarks } = useBookmarkContext();
|
2024-08-08 18:16:17 +02:00
|
|
|
|
2024-07-29 07:45:59 -07:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{header}
|
2024-08-16 10:30:14 +02:00
|
|
|
{bookmarks.length > 0 && <div className="my-1.5 h-px" role="none" />}
|
2024-08-22 17:09:05 -04:00
|
|
|
{bookmarks.map((bookmark, i) => (
|
2024-08-08 18:16:17 +02:00
|
|
|
<BookmarkItem
|
2024-08-22 17:09:05 -04:00
|
|
|
key={`${bookmark._id ?? bookmark.tag}-${i}`}
|
2024-08-08 18:16:17 +02:00
|
|
|
tag={bookmark.tag}
|
|
|
|
|
selected={tags.includes(bookmark.tag)}
|
|
|
|
|
handleSubmit={handleSubmit}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
2024-07-29 07:45:59 -07:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
2024-08-08 18:16:17 +02:00
|
|
|
|
2024-07-29 07:45:59 -07:00
|
|
|
export default BookmarkItems;
|