Changed lotsa stuff

This commit is contained in:
mrfry 2021-03-23 15:34:26 +01:00
parent 91eb5cd839
commit 7bb7b919ae
18 changed files with 457 additions and 447 deletions

View file

@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React from 'react'
import Head from 'next/head'
import Sleep from '../components/sleep'
@ -9,57 +9,6 @@ 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>
@ -88,7 +37,6 @@ export default function contribute() {
Itt írhatsz új todo-ra ötleteket, vagy jelezhetsz hogy egyikben
segítenél
</div>
{renderNewTaskArea()}
<hr />
<Todos />
<Sleep />