Merge branch 'new_style-2' into new_style

This commit is contained in:
mrfry 2021-03-23 20:01:24 +01:00
commit 03aefe21b4
18 changed files with 461 additions and 522 deletions

View file

@ -1,65 +1,15 @@
import React, { useState } from 'react'
import React from 'react'
import Head from 'next/head'
import Sleep from '../components/sleep'
import Todos from '../components/todoStuff/todos'
import FeedbackArea from '../components/feedbackArea'
import constants from '../constants.json'
import styles from './contribute.module.css'
import repos from '../data/repos.json'
export default function contribute() {
const [newTask, setNewTask] = useState('')
const submitNewTask = async () => {
if (!newTask) {
return
}
fetch(constants.apiUrl + 'postfeedback', {
method: 'POST',
credentials: 'include',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
newTask: newTask,
from: 'contribute',
}),
})
.then((resp) => {
return resp.json()
})
.then((resp) => {
if (resp.success) {
alert('Elküldve')
setNewTask('')
} else {
alert('Hiba küldés közben')
}
})
.catch((err) => {
alert('Hiba küldés közben')
console.error(err)
})
}
const renderNewTaskArea = () => {
return (
<div className={styles.inputArea}>
<textarea
onChange={(event) => setNewTask(event.target.value)}
value={newTask || ''}
className={styles.feedback}
/>
<button className={styles.button} onClick={submitNewTask}>
Küldés
</button>
</div>
)
}
return (
<div>
<Head>
@ -98,7 +48,7 @@ export default function contribute() {
</a>
-n és megbeszéljük.
</div>
{renderNewTaskArea()}
<FeedbackArea from={'contribute'} />
<hr />
<Todos />
<Sleep />