From b2034089cdd1c740a19b9cf6dffe7ed6526f156e Mon Sep 17 00:00:00 2001 From: mrfry Date: Fri, 5 Mar 2021 20:02:11 +0100 Subject: [PATCH] Changed api endpoints --- src/components/modal.module.css | 2 +- src/components/newsEntry.js | 7 +-- src/components/tooltip.module.css | 2 +- src/pages/index.js | 84 +++++++++++++++---------------- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/components/modal.module.css b/src/components/modal.module.css index a1a03e2..19aa27e 100644 --- a/src/components/modal.module.css +++ b/src/components/modal.module.css @@ -1,5 +1,5 @@ .modal { - z-index: 9999; + z-index: 99; position: fixed; top: 0; left: 0; diff --git a/src/components/newsEntry.js b/src/components/newsEntry.js index f980347..c29bca7 100644 --- a/src/components/newsEntry.js +++ b/src/components/newsEntry.js @@ -8,7 +8,8 @@ import styles from './newsEntry.module.css' export default function NewsEntry({ newsItem, uid, - onReact, + onCommentReact, + onNewsReact, onComment, onDelete, onPostDelete, @@ -47,14 +48,14 @@ export default function NewsEntry({ existingReacts={reacts} uid={uid} onClick={(reaction, isDelete) => { - onReact({ type: 'news', reaction, isDelete }) + onNewsReact({ reaction, isDelete }) }} /> { - onReact({ type: 'comment', path, reaction, isDelete }) + onCommentReact({ path, reaction, isDelete }) }} onComment={onComment} onDelete={onDelete} diff --git a/src/components/tooltip.module.css b/src/components/tooltip.module.css index b7beba2..2f05f33 100644 --- a/src/components/tooltip.module.css +++ b/src/components/tooltip.module.css @@ -15,7 +15,7 @@ border-radius: 6px; padding: 5px; position: absolute; - z-index: 1; + z-index: 9999; bottom: 100%; left: 0%; margin-left: -60px; diff --git a/src/pages/index.js b/src/pages/index.js index 1700aa2..18987f7 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -143,50 +143,50 @@ export default function Index({ globalData }) { setNews(res.news) }) }} - onReact={({ type, path, reaction, isDelete }) => { - if (type === 'news') { - fetch(constants.apiUrl + 'infos', { - method: 'POST', - credentials: 'include', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - react: reaction, - newsKey: key, - isDelete: isDelete, - }), + onNewsReact={({ reaction, isDelete }) => { + fetch(constants.apiUrl + 'react', { + method: 'POST', + credentials: 'include', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + reaction: reaction, + newsKey: key, + isDelete: isDelete, + }), + }) + .then((res) => { + return res.json() }) - .then((res) => { - return res.json() - }) - .then((res) => { - setNews(res.news) - }) - } else if (type === 'comment') { - fetch(constants.apiUrl + 'comment', { - method: 'POST', - credentials: 'include', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - type: 'reaction', - newsKey: key, - path: path, - reaction: reaction, - isDelete: isDelete, - }), + .then((res) => { + console.log(res) + setNews(res.news) + }) + }} + onCommentReact={({ path, reaction, isDelete }) => { + fetch(constants.apiUrl + 'react', { + method: 'POST', + credentials: 'include', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + type: 'reaction', + newsKey: key, + path: path, + reaction: reaction, + isDelete: isDelete, + }), + }) + .then((res) => { + return res.json() + }) + .then((res) => { + setNews(res.news) }) - .then((res) => { - return res.json() - }) - .then((res) => { - setNews(res.news) - }) - } }} onDelete={(path) => { fetch(constants.apiUrl + 'comment', {