mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Frontpage removed private feedback, added file uploader to contacts
This commit is contained in:
parent
76f96ba8aa
commit
9c194277b3
6 changed files with 96 additions and 160 deletions
|
@ -58,48 +58,6 @@ function addPost(title, content) {
|
|||
})
|
||||
}
|
||||
|
||||
function postFeedback(content, file) {
|
||||
return new Promise((resolve) => {
|
||||
const promises = [
|
||||
fetch(constants.apiUrl + 'postfeedback', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: content,
|
||||
}),
|
||||
}).then((res) => {
|
||||
return res.json()
|
||||
}),
|
||||
]
|
||||
|
||||
if (file) {
|
||||
const formData = new FormData() // eslint-disable-line
|
||||
formData.append('file', file)
|
||||
|
||||
promises.push(
|
||||
fetch(constants.apiUrl + 'postfeedbackfile', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
body: formData,
|
||||
}).then((res) => {
|
||||
return res.json()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
Promise.all(promises).then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function updateForumPost(forum, postKey, postData) {
|
||||
return Object.keys(forum).reduce((acc, key) => {
|
||||
const entry = forum[key]
|
||||
|
@ -293,30 +251,15 @@ export default function Index({ globalData }) {
|
|||
<div className={styles.title}>Fórum/Hírek</div>
|
||||
<hr />
|
||||
<Composer
|
||||
onSubmit={(type, title, content, file) => {
|
||||
if (!content) {
|
||||
alert('Üres a tartalom!')
|
||||
return
|
||||
}
|
||||
if (type === 'private') {
|
||||
postFeedback(content, file).then((res) => {
|
||||
console.log(res)
|
||||
alert('Privát visszajelzés elküldve!')
|
||||
})
|
||||
} else {
|
||||
if (!title) {
|
||||
alert('Üres a téma!')
|
||||
return
|
||||
onSubmit={(title, content) => {
|
||||
addPost(title, content).then((res) => {
|
||||
const { success, newPostKey, newEntry, msg } = res
|
||||
if (success) {
|
||||
setNews({ [newPostKey]: newEntry, ...news })
|
||||
} else {
|
||||
alert(msg)
|
||||
}
|
||||
addPost(title, content).then((res) => {
|
||||
const { success, newPostKey, newEntry, msg } = res
|
||||
if (success) {
|
||||
setNews({ [newPostKey]: newEntry, ...news })
|
||||
} else {
|
||||
alert(msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<div>{newsItems}</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue