diff --git a/src/constants.json b/src/constants.json index dec44ec..8650745 100644 --- a/src/constants.json +++ b/src/constants.json @@ -1,6 +1,6 @@ { "siteUrl": "https://qmining.frylabs.net/", - "apiUrl": "http://localhost:8080/", + "apiUrl": "https://api.frylabs.net/", "mobileWindowWidth": 700, "maxQuestionsToRender": 250 } diff --git a/src/pages/contribute.js b/src/pages/contribute.js index 0030376..c72c15b 100644 --- a/src/pages/contribute.js +++ b/src/pages/contribute.js @@ -1,20 +1,75 @@ -import React from 'react' +import React, { useState } from 'react' import Button from '../components/Button.js' import Sleep from '../components/sleep' import TodoTable from '../components/todoStuff/todoTable' +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 ( +