mirror of
https://github.com/IgnatZakalinsky/home-works.git
synced 2026-01-27 12:32:42 +00:00
add hw 13
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
69
src/s2-homeworks/hw13/HW13.tsx
Normal file
69
src/s2-homeworks/hw13/HW13.tsx
Normal 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
|
||||
Reference in New Issue
Block a user