- {props.category.bookmarks.map((bookmark: Bookmark) => {
+ {category.bookmarks.map((bookmark: Bookmark) => {
const redirectUrl = urlParser(bookmark.url)[1];
let iconEl: JSX.Element =
;
diff --git a/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx b/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx
index 01a5ed1..7e26c32 100644
--- a/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx
+++ b/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx
@@ -11,27 +11,39 @@ interface Props {
categories: Category[];
totalCategories?: number;
searching: boolean;
+ fromHomepage?: boolean;
}
export const BookmarkGrid = (props: Props): JSX.Element => {
+ const {
+ categories,
+ totalCategories,
+ searching,
+ fromHomepage = false,
+ } = props;
+
let bookmarks: JSX.Element;
- if (props.categories.length) {
- if (props.searching && !props.categories[0].bookmarks.length) {
+ if (categories.length) {
+ if (searching && !categories[0].bookmarks.length) {
bookmarks =
No bookmarks match your search criteria;
} else {
bookmarks = (
- {props.categories.map(
+ {categories.map(
(category: Category): JSX.Element => (
-
+
)
)}
);
}
} else {
- if (props.totalCategories) {
+ if (totalCategories) {
bookmarks = (
There are no pinned categories. You can pin them from the{' '}
diff --git a/client/src/components/Bookmarks/Bookmarks.tsx b/client/src/components/Bookmarks/Bookmarks.tsx
index f461d48..5bbe324 100644
--- a/client/src/components/Bookmarks/Bookmarks.tsx
+++ b/client/src/components/Bookmarks/Bookmarks.tsx
@@ -69,12 +69,17 @@ export const Bookmarks = (props: Props): JSX.Element => {
}, [isAuthenticated]);
useEffect(() => {
- if (categoryInEdit && !showTable) {
+ if (categoryInEdit) {
setTableContentType(ContentType.bookmark);
setShowTable(true);
}
}, [categoryInEdit]);
+ useEffect(() => {
+ setShowTable(false);
+ setEditCategory(null);
+ }, []);
+
// Form actions
const toggleModal = (): void => {
setModalIsOpen(!modalIsOpen);
@@ -108,6 +113,7 @@ export const Bookmarks = (props: Props): JSX.Element => {
const showTableForEditing = (contentType: ContentType) => {
// We're in the edit mode and the same button was clicked - go back to list
if (showTable && contentType === tableContentType) {
+ setEditCategory(null);
setShowTable(false);
} else {
setShowTable(true);
diff --git a/client/src/components/Home/Home.tsx b/client/src/components/Home/Home.tsx
index d369aaa..e24e5c0 100644
--- a/client/src/components/Home/Home.tsx
+++ b/client/src/components/Home/Home.tsx
@@ -151,6 +151,7 @@ export const Home = (): JSX.Element => {
}
totalCategories={categories.length}
searching={!!localSearch}
+ fromHomepage={true}
/>
)}