Changed api endpoints

This commit is contained in:
mrfry 2021-03-05 20:02:11 +01:00
parent d84948918f
commit b2034089cd
4 changed files with 48 additions and 47 deletions

View file

@ -1,5 +1,5 @@
.modal { .modal {
z-index: 9999; z-index: 99;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;

View file

@ -8,7 +8,8 @@ import styles from './newsEntry.module.css'
export default function NewsEntry({ export default function NewsEntry({
newsItem, newsItem,
uid, uid,
onReact, onCommentReact,
onNewsReact,
onComment, onComment,
onDelete, onDelete,
onPostDelete, onPostDelete,
@ -47,14 +48,14 @@ export default function NewsEntry({
existingReacts={reacts} existingReacts={reacts}
uid={uid} uid={uid}
onClick={(reaction, isDelete) => { onClick={(reaction, isDelete) => {
onReact({ type: 'news', reaction, isDelete }) onNewsReact({ reaction, isDelete })
}} }}
/> />
</div> </div>
<Comments <Comments
uid={uid} uid={uid}
onReact={(path, reaction, isDelete) => { onReact={(path, reaction, isDelete) => {
onReact({ type: 'comment', path, reaction, isDelete }) onCommentReact({ path, reaction, isDelete })
}} }}
onComment={onComment} onComment={onComment}
onDelete={onDelete} onDelete={onDelete}

View file

@ -15,7 +15,7 @@
border-radius: 6px; border-radius: 6px;
padding: 5px; padding: 5px;
position: absolute; position: absolute;
z-index: 1; z-index: 9999;
bottom: 100%; bottom: 100%;
left: 0%; left: 0%;
margin-left: -60px; margin-left: -60px;

View file

@ -143,50 +143,50 @@ export default function Index({ globalData }) {
setNews(res.news) setNews(res.news)
}) })
}} }}
onReact={({ type, path, reaction, isDelete }) => { onNewsReact={({ reaction, isDelete }) => {
if (type === 'news') { fetch(constants.apiUrl + 'react', {
fetch(constants.apiUrl + 'infos', { method: 'POST',
method: 'POST', credentials: 'include',
credentials: 'include', headers: {
headers: { Accept: 'application/json',
Accept: 'application/json', 'Content-Type': 'application/json',
'Content-Type': 'application/json', },
}, body: JSON.stringify({
body: JSON.stringify({ reaction: reaction,
react: reaction, newsKey: key,
newsKey: key, isDelete: isDelete,
isDelete: isDelete, }),
}), })
.then((res) => {
return res.json()
}) })
.then((res) => { .then((res) => {
return res.json() console.log(res)
}) setNews(res.news)
.then((res) => { })
setNews(res.news) }}
}) onCommentReact={({ path, reaction, isDelete }) => {
} else if (type === 'comment') { fetch(constants.apiUrl + 'react', {
fetch(constants.apiUrl + 'comment', { method: 'POST',
method: 'POST', credentials: 'include',
credentials: 'include', headers: {
headers: { Accept: 'application/json',
Accept: 'application/json', 'Content-Type': 'application/json',
'Content-Type': 'application/json', },
}, body: JSON.stringify({
body: JSON.stringify({ type: 'reaction',
type: 'reaction', newsKey: key,
newsKey: key, path: path,
path: path, reaction: reaction,
reaction: reaction, isDelete: isDelete,
isDelete: isDelete, }),
}), })
.then((res) => {
return res.json()
})
.then((res) => {
setNews(res.news)
}) })
.then((res) => {
return res.json()
})
.then((res) => {
setNews(res.news)
})
}
}} }}
onDelete={(path) => { onDelete={(path) => {
fetch(constants.apiUrl + 'comment', { fetch(constants.apiUrl + 'comment', {