Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import Button from 'antd/lib/button'; import Form from 'antd/lib/form'; import { FormComponentProps } from 'antd/lib/form/Form'; import Icon from 'antd/lib/icon'; import Input from 'antd/lib/input'; import message from 'antd/lib/message'; import * as React from 'react'; import { connect } from 'react-redux'; import { useBoolean } from '../../../customHooks'; import { authSetAuthDataAction, authSetAuthStateAction } from '../actions'; import { forgotPassword } from '../api'; import { AUTH_STATE_FORGOT_PASSWORD_SUBMIT } from '../constants'; interface IProps extends FormComponentProps { setAuthState: any; setAuthData: any; } const ForgotPassword = ({ form, setAuthState, setAuthData }: IProps) => { const isLoading = useBoolean(false); const handleSubmit = (e: any) => { e.preventDefault(); form.validateFields(async (err: any, values: any) => { if (!err) { try { isLoading.setTrue(); const data: any = await forgotPassword(values.username); await setAuthData({ username: values.username }); isLoading.setFalse(); message.info( `Bezpečnostní kód pro změnu hesla Vám byl odeslán na email ${ data.CodeDeliveryDetails.Destination }`, ); await setAuthState(AUTH_STATE_FORGOT_PASSWORD_SUBMIT); } catch (e) { isLoading.setFalse(); message.error(e.message); } } }); }; const { getFieldDecorator } = form; return ( <Form onSubmit={handleSubmit}> <Form.Item> {getFieldDecorator('username', { rules: [ { required: true, message: 'Prosím zadejte uživatelské jméno!' }, ], })( <Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="Uživatelské jméno" />, )} </Form.Item> <Form.Item> <Button type="primary" htmlType="submit" loading={isLoading.value}> Potvrdit </Button> </Form.Item> </Form> ); }; export default connect( () => ({}), { setAuthState: authSetAuthStateAction, setAuthData: authSetAuthDataAction, }, )(Form.create()(ForgotPassword)); |