import React, { useState } from "react"; import { Button, Card, Input, Space } from "antd"; import { Form, Field } from "react-final-form"; import { UserOutlined } from "@ant-design/icons"; import { resetPass } from "../API/auth/resetPass"; import Success from "./Success"; const ResetPassword: React.FC = () => { const [open, setOpen] = useState(false); const [email, setEmail] = useState(""); const validate = (val: any) => { const err: any = {}; if (!val.login) { err.login = "Required"; } return err; }; const sleep = (ms: any) => new Promise((resolve) => setTimeout(resolve, ms)); const onSubmit = async (values: any) => { setEmail(values.login); await sleep(300); await resetPass({ login: values.login }).then(() => { setOpen(true); }); }; return (
( {({ input, meta }) => (
} size={"large"} {...input} type="text" placeholder="username or e-mail" /> {(meta.error || meta.submitError) && meta.touched && ( {meta.error || meta.submitError} )}
)}
{submitError && (
{submitError}
)}
)} />
); }; export default ResetPassword;