"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PasswordRecovery = void 0;
var React = require("react");
var Yup = require("yup");
var react_router_dom_1 = require("react-router-dom");
var formik_1 = require("formik");
var routes_1 = require("../../../../apiClient/routes");
var httpService_1 = require("../../../../services/httpService");
var react_toastify_1 = require("react-toastify");
var PasswordRecovery = function (props) {
    React.useEffect(function () {
        document.title = "Zapomenuté heslo";
    }, []);
    var handleSubmit = function (values) {
        httpService_1.default.post(routes_1.AccountController_RecoverPassword, values).then(function (response) {
            react_toastify_1.toast.success('👍 Žádost o obnovení hesla odeslána! Zkontrolujte evůj email.', {
                position: "top-right",
                autoClose: 3000,
                hideProgressBar: true,
                closeOnClick: true,
                pauseOnHover: false,
                draggable: true,
                progress: undefined,
            });
            props.history.push("/login");
        }).catch(function (e) {
            console.log(e);
        });
    };
    var passwordRecoveryValidationSchema = Yup.object().shape({
        email: Yup.string().required("Zadejte emailovou adresu!").email("Nevalidní emailová adresa!")
    });
    return (React.createElement("div", { className: "container" },
        React.createElement("div", { className: "row" },
            React.createElement("div", { className: "col-lg-3" }),
            React.createElement("div", { className: "col-lg-6" },
                React.createElement(formik_1.Formik, { initialValues: { email: '' }, validationSchema: passwordRecoveryValidationSchema, onSubmit: function (values) { handleSubmit(values); } }, function (_a) {
                    var errors = _a.errors, handleReset = _a.handleReset, handleSubmit = _a.handleSubmit, touched = _a.touched;
                    return (React.createElement(formik_1.Form, { onReset: handleReset, onSubmit: handleSubmit },
                        React.createElement("div", { className: "checkout__input" },
                            React.createElement("p", null,
                                "Email",
                                React.createElement("span", null, "*")),
                            React.createElement(formik_1.Field, { name: "email", type: "email", placeholder: "Emailov\u00E1 adresa", className: (touched.email && errors.email)
                                    ? 'input__error'
                                    : (touched.email && !errors.email ? 'input__success' : '') }),
                            errors && touched.email && errors.email && React.createElement(React.Fragment, null,
                                React.createElement("label", { className: "error-message" }, errors.email))),
                        React.createElement("button", { type: "submit", className: "site-btn" }, "Obnovit heslo"),
                        React.createElement("div", { className: "d-flex justify-content-center mt-2" },
                            React.createElement("p", null,
                                React.createElement(react_router_dom_1.Link, { className: "login__link", to: "/login" }, "-> Zpět na přihlášení <-")))));
                })),
            React.createElement("div", { className: "col-lg-3" }))));
};
exports.PasswordRecovery = PasswordRecovery;
//# sourceMappingURL=PasswordRecovery.js.map