- Ha egy kérdésre mindig helytelenül talál választ a userscript (vagy egyéb hibát észlelsz), akkor
- azon az oldalon nyomj egy ctrl-s -t. Ez lementi a weboldalt úgy ahogy van egy mappába, és egy
- html fájlba. Ezt a kettőt ha berakod egy .zip-be, és ide feltöltöd, akkor ránézek mi lehet a
- hiba, és kijavítom.
Ha több, elég a .html. Bónusz ha mellékelsz egy
- readme-t, hogy mit csináljak.
+
-
)
}
- const renderFeedback = () => {
+ const onFileChangeHandler = (e) => {
+ setFile(e.target.files[0])
+ }
+
+ const renderFileUploader = () => {
return (
-
-
+
)
}
+ const handleSubmit = async () => {
+ if (!form.description) {
+ setResult(results.invalid)
+ return
+ }
+
+ const rawResponse = await fetch('http://localhost:8080/postfeedback', {
+ method: 'POST',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(form)
+ })
+ rawResponse.json()
+ .then((resp) => {
+ if (resp.success) {
+ setResult(results.success)
+ } else {
+ console.log(resp)
+ setResult(results.error)
+ }
+ })
+ .catch((e) => {
+ setResult(results.error)
+ console.log(e)
+ })
+
+ if (file) {
+ const formData = new FormData() // eslint-disable-line
+ formData.append('file', file)
+
+ const rawFileResponse = await fetch('http://localhost:8080/postfeedbackfile', {
+ method: 'POST',
+ headers: {
+ 'Accept': 'application/json'
+ },
+ body: formData
+ })
+ rawFileResponse.json()
+ .then((resp) => {
+ if (resp.success) {
+ setFileResult(results.success)
+ } else {
+ console.log(resp)
+ setFileResult(results.error)
+ }
+ })
+ .catch((e) => {
+ setFileResult(results.error)
+ console.log('FILE', e)
+ })
+ }
+ }
+
+ const renderResult = () => {
+ if (results === result.success) {
+ return (
+
+ sucess
+
+ )
+ } else if (results === result.error) {
+ return (
+
+ error
+
+ )
+ } else if (results === result.invalid) {
+ return (
+
+ invalid
+
+ )
+ } else {
+ return null
+ }
+ }
+
+ // action={constants.apiUrl + 'badtestsender'} encType='multipart/form-data' method='post'
+ const renderForm = (props) => {
+ return (
+
+ {props.noDesc
+ ?
+ Mező kitöltése kötelező!
+
+ : null}
+ {renderTextInputArea({
+ text: 'Rövid leírás',
+ name: 'description',
+ onChange: onChange
+ })}
+ {renderTextInputArea({
+ text: 'Lépések amikkel előáll a hiba',
+ name: 'steps',
+ onChange: onChange
+ })}
+ {renderTextInputArea({
+ text: 'Elvárt működés',
+ name: 'expected',
+ onChange: onChange
+ })}
+ {renderTextInputArea({
+ text: 'Ami történik helyette',
+ name: 'current',
+ onChange: onChange
+ })}
+ {renderFileUploader()}
+
+
+ Küldés
+
+ {renderResult()}
+
+ )
+ }
+
+ console.log('result', result, 'fileResult', fileResult)
+ const renderStuff = () => {
+ if (result === results.notSent && fileResult === results.notSent) {
+ console.log('both not sent')
+ return (
+
+ {renderForm({})}
+
+ )
+ } else if (result === results.invalid) {
+ console.log('result is invalid')
+ return (
+
+ {renderForm({ noDesc: true })}
+
+ )
+ } else if (result === results.success && !file) {
+ console.log('text sucess, no file')
+ return (
+
+ Visszajelzés elküldve c:
+
+ )
+ } else if (result === results.error && fileResult === results.success) {
+ console.log('file sucess only')
+ return (
+
+ Hiba küldés közben :c
+
+ )
+ } else if (result === results.success && fileResult === results.error) {
+ console.log('text sucess only')
+ return (
+
+ Visszajelzés elküldve, de fájlt nem sikerült elküldeni :c
+
+ )
+ } else if (result === results.success && fileResult === results.success) {
+ console.log('both sucess')
+ return (
+
+ Visszajelzés elküldve c:
+
+ )
+ } else {
+ console.log('else')
+ }
+ }
+
return (
- {renderFeedback()}
-
-
-
- {renderTestSender()}
+ {renderStuff()}
)
}
diff --git a/src/pages/feedback.module.css b/src/pages/feedback.module.css
new file mode 100644
index 0000000..a9f9721
--- /dev/null
+++ b/src/pages/feedback.module.css
@@ -0,0 +1,33 @@
+.feedback {
+ color: var(--text-color);
+ background-color: var(--background-color);
+ font-size: 18px;
+ width: 100%;
+ box-sizing: border-box;
+ height: 120px;
+}
+
+.textTitle {
+ color: var(--text-color);
+ font-size: 26px;
+}
+
+.button {
+ background-color: var(--text-color);
+ border: none;
+ padding: 10px 30px;
+ color: white;
+}
+
+.textInputArea {
+ margin: 10px;
+}
+
+.fileInput {
+ margin: 10px;
+ color: var(--text-color);
+}
+
+.errorMsg {
+ color: red;
+}
diff --git a/src/pages/index.js b/src/pages/index.js
index 6e9fae3..2199e0a 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -6,6 +6,7 @@ import fetch from 'unfetch'
import LoadingIndicator from '../components/LoadingIndicator'
+import styles from './index.module.css'
import links from '../data/links.json'
import constants from '../constants.json'
@@ -46,7 +47,13 @@ export default function Index (props) {
{key}: