add hw 13

This commit is contained in:
neko
2022-06-19 20:37:26 +03:00
parent f4b13b891e
commit 10b630c34b
4 changed files with 94 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ import React from 'react'
import HW10 from '../../hw10/HW10'
import HW11 from '../../hw11/HW11'
import HW12 from '../../hw12/HW12'
import HW13 from '../../hw13/HW13'
function JuniorPlus() {
return (
@@ -10,7 +11,7 @@ function JuniorPlus() {
<HW10/>
<HW11/>
<HW12/>
{/*<HW13/>*/}
<HW13/>
</div>
)
}

View File

@@ -0,0 +1,69 @@
import React, {useState} from 'react'
import s2 from '../../s1-main/App.module.css'
import SuperButton from '../hw04/common/c2-SuperButton/SuperButton'
import axios from 'axios'
const HW13 = () => {
const [answer, setAnswer] = useState('')
const [info, setInfo] = useState('')
const send = (x?: boolean) => () => {
setAnswer('...loading')
setInfo('...loading')
axios.post('https://neko-cafe-back.herokuapp.com/auth/test', {success: x})
.then(res => {
setAnswer(res.data.errorText)
setInfo(res.data.info)
})
.catch(e => {
setAnswer(e.response.data.errorText)
setInfo(e.response.data.info)
})
}
return (
<div id={'hw13'} className={s2.hw}>
<hr/>
{/*можно убрать этот тег*/}
<div className={s2.hwTitle}>homeworks 13</div>
{/*для автоматической проверки дз (не менять)*/}
<SuperButton
id={'hw13-send-true'}
onClick={send(true)}
disabled={answer === '...loading'}
>
send true
</SuperButton>
<SuperButton
id={'hw13-send-false'}
onClick={send(false)}
disabled={answer === '...loading'}
>
send false
</SuperButton>
<SuperButton
id={'hw13-send-undefined'}
onClick={send(undefined)}
disabled={answer === '...loading'}
>
send undefined
</SuperButton>
<div id={'hw13-answer'}>
{answer}
</div>
<div id={'hw13-info'}>
{info}
</div>
<hr/>
{/*можно убрать этот тег*/}
<hr/>
{/*можно убрать этот тег*/}
</div>
)
}
export default HW13