mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Added pw request page files
This commit is contained in:
parent
f07a1749f5
commit
42e6d4dd4c
2 changed files with 103 additions and 0 deletions
61
src/pages/pwRequest.js
Normal file
61
src/pages/pwRequest.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
import React, { useState } from 'react'
|
||||
import fetch from 'unfetch'
|
||||
|
||||
import styles from './pwRequest.module.css'
|
||||
import constants from '../constants.json'
|
||||
|
||||
export default function PwRequest (props) {
|
||||
const [resul, setResult] = useState()
|
||||
const [remaining, setRemaining] = useState()
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const rawResponse = await fetch(constants.apiUrl + 'getpw', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({})
|
||||
})
|
||||
rawResponse.json()
|
||||
.then((resp) => {
|
||||
if (resp.result === 'success') {
|
||||
setResult(resp.pw)
|
||||
setRemaining(resp.remaining)
|
||||
} else if (resp.result === 'success') {
|
||||
setResult('Nem vagy bejelentkezve!') // this should never happpen
|
||||
} else {
|
||||
setResult('Jelszó kérési lehetőségeid jelenleg nincsenek, nézz vissza később')
|
||||
setRemaining(0)
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
setResult('Szerver oldali hiba!')
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div id='form'>
|
||||
<div className={styles.text}>
|
||||
Itt Egy új jelszót tudsz kérni új felhasználóknak. Korlátozott mennyiségű jelszót tudsz
|
||||
csak kérni, de ez idővel visszatöltődik, szóval óvatosan. Közös jelszóhasználat nem
|
||||
ajánlott, mert ha belépsz valahol akkor azonnal kijelentkeztet mindenhonnan máshonnan.
|
||||
Szerintem van elég jelszó hogy ne kelljen közös
|
||||
</div>
|
||||
<div className={styles.buttonContainer}>
|
||||
<div
|
||||
onClick={handleSubmit}
|
||||
className={styles.button}
|
||||
>
|
||||
Jelszó kérése
|
||||
</div>
|
||||
</div>
|
||||
{resul ? <div className={styles.pw}>{resul}</div> : null}
|
||||
{remaining ? <div className={styles.remaining}>Még kérhető jelszavak: {remaining}</div> : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
42
src/pages/pwRequest.module.css
Normal file
42
src/pages/pwRequest.module.css
Normal file
|
@ -0,0 +1,42 @@
|
|||
.buttonContainer {
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
background-color: var(--text-color);
|
||||
border: none;
|
||||
padding: 10px 30px;
|
||||
color: white;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.text {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.pw {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
color: white;
|
||||
padding: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.remaining {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.form {
|
||||
margin: 0px;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue