From d020fd4c0f21cae0e1ea4319e77b1aadc516a3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Darveau?= Date: Sun, 27 Jun 2021 15:17:23 -0400 Subject: [PATCH] Add custom icons to bookmarks (#5) * allow custom icons for bookmarks * update docker-image action to tag images based on source branch --- .../components/Bookmarks/BookmarkForm/BookmarkForm.tsx | 9 ++++----- client/src/components/Bookmarks/Bookmarks.tsx | 6 +++--- controllers/bookmark.js | 6 ++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/src/components/Bookmarks/BookmarkForm/BookmarkForm.tsx b/client/src/components/Bookmarks/BookmarkForm/BookmarkForm.tsx index 4eb2937..c9506e9 100644 --- a/client/src/components/Bookmarks/BookmarkForm/BookmarkForm.tsx +++ b/client/src/components/Bookmarks/BookmarkForm/BookmarkForm.tsx @@ -42,8 +42,8 @@ const BookmarkForm = (props: ComponentProps): JSX.Element => { }); const [bookmarkData, setBookmarkData] = useState({ - name: '', - url: '', + name: "", + url: "", categoryId: -1, icon: '', }); @@ -68,8 +68,8 @@ const BookmarkForm = (props: ComponentProps): JSX.Element => { }); } else { setBookmarkData({ - name: '', - url: '', + name: "", + url: "", categoryId: -1, icon: '', }); @@ -113,7 +113,6 @@ const BookmarkForm = (props: ComponentProps): JSX.Element => { } else { props.addBookmark(bookmarkData); } - setBookmarkData({ name: "", url: "", diff --git a/client/src/components/Bookmarks/Bookmarks.tsx b/client/src/components/Bookmarks/Bookmarks.tsx index cd1b181..e8c23d0 100644 --- a/client/src/components/Bookmarks/Bookmarks.tsx +++ b/client/src/components/Bookmarks/Bookmarks.tsx @@ -50,10 +50,10 @@ const Bookmarks = (props: ComponentProps): JSX.Element => { updatedAt: new Date(), }); const [bookmarkInUpdate, setBookmarkInUpdate] = useState({ - name: "", - url: "", + name: "string", + url: "string", categoryId: -1, - icon: "", + icon: "string", isPinned: false, orderId: 0, id: 0, diff --git a/controllers/bookmark.js b/controllers/bookmark.js index 4445dbc..9fe6097 100644 --- a/controllers/bookmark.js +++ b/controllers/bookmark.js @@ -13,6 +13,12 @@ exports.createBookmark = asyncWrapper(async (req, res, next) => { }); let bookmark; + let _body = { ...req.body }; + + if (req.file) { + _body.icon = req.file.filename; + } + let _body = { ...req.body,