"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var Yup = require("yup");
var formik_1 = require("formik");
var react_bootstrap_1 = require("react-bootstrap");
var ViewModels_1 = require("../../../../apiModels/ViewModels");
function AddressFormModal(_a) {
    var onCreateAddressModalClose = _a.onCreateAddressModalClose, onCreateAddressModalSubmit = _a.onCreateAddressModalSubmit, show = _a.show;
    var addressValidationSchema = Yup.object().shape({
        firstName: Yup.string().required("Jméno je vyžadováno!"),
        lastName: Yup.string().required("Příjmení je vyžadováno!"),
        phoneNumber: Yup.string().required("Telefonní číslo je vyžadováno!"),
        city: Yup.string().required("Město je vyžadováno!"),
        street: Yup.string().required("Ulice je vyžadována!"),
        zipCode: Yup.string().required("PSČ je vyžadováno!"),
        addressTypeID: Yup.string().required("Zvolte typ adresy!")
    });
    var initAddress = {
        id: 0,
        firstName: '',
        lastName: '',
        phoneNumber: '',
        city: '',
        street: '',
        zipCode: '',
        email: '',
        addressTypeID: ''
    };
    return (React.createElement(React.Fragment, null,
        React.createElement(react_bootstrap_1.Modal, { show: show, onHide: onCreateAddressModalClose, backdrop: "static", keyboard: false },
            React.createElement(react_bootstrap_1.Modal.Header, { closeButton: true },
                React.createElement(react_bootstrap_1.Modal.Title, null, "Nov\u00E1 adresa")),
            React.createElement(formik_1.Formik, { initialValues: initAddress, validationSchema: addressValidationSchema, enableReinitialize: true, onSubmit: function (values) { onCreateAddressModalSubmit(values); } }, function (_a) {
                var errors = _a.errors, handleSubmit = _a.handleSubmit, touched = _a.touched;
                return (React.createElement(formik_1.Form, { onSubmit: handleSubmit },
                    React.createElement(react_bootstrap_1.Modal.Body, null,
                        React.createElement("div", { className: "row", style: { marginBottom: '24px' } },
                            React.createElement("div", { className: "col-lg col-md" },
                                React.createElement("p", null,
                                    "Typ adresy",
                                    React.createElement("span", null, "*")),
                                React.createElement("div", { className: "form-check" },
                                    React.createElement(formik_1.Field, { type: "radio", value: ViewModels_1.AddressType.DeliveryAddress.toString(), name: "addressTypeID", className: "form-check-input" }),
                                    "Doru\u010Dovac\u00ED"),
                                React.createElement("div", { className: "form-check" },
                                    React.createElement(formik_1.Field, { type: "radio", value: ViewModels_1.AddressType.InvoicingAddress.toString(), name: "addressTypeID", className: "form-check-input" }),
                                    "Faktura\u010Dn\u00ED"),
                                errors.addressTypeID && touched.addressTypeID && React.createElement("label", { className: "error-message" }, errors.addressTypeID))),
                        React.createElement("div", { className: "row" },
                            React.createElement("div", { className: "col-lg-6" },
                                React.createElement("div", { className: "checkout__input" },
                                    React.createElement("p", null,
                                        "Jm\u00E9no",
                                        React.createElement("span", null, "*")),
                                    React.createElement(formik_1.Field, { name: "firstName", type: "text", placeholder: "Jm\u00E9no", className: (touched.firstName && errors.firstName)
                                            ? 'input__error'
                                            : (touched.firstName && !errors.firstName ? 'input__success' : '') }),
                                    errors && errors.firstName && touched.firstName && React.createElement("label", { className: "error-message" }, errors.firstName))),
                            React.createElement("div", { className: "col-lg-6" },
                                React.createElement("div", { className: "checkout__input" },
                                    React.createElement("p", null,
                                        "P\u0159\u00EDjmen\u00ED",
                                        React.createElement("span", null, "*")),
                                    React.createElement(formik_1.Field, { name: "lastName", type: "text", placeholder: "P\u0159\u00EDjmen\u00ED", className: (touched.lastName && errors.lastName)
                                            ? 'input__error'
                                            : (touched.lastName && !errors.lastName ? 'input__success' : '') }),
                                    errors.lastName && touched.lastName && React.createElement("label", { className: "error-message" }, errors.lastName)))),
                        React.createElement("div", { className: "checkout__input" },
                            React.createElement("p", null,
                                "M\u011Bsto a ulice",
                                React.createElement("span", null, "*")),
                            React.createElement(formik_1.Field, { name: "city", type: "text", placeholder: "M\u011Bsto", className: (touched.city && errors.city)
                                    ? 'checkout__input__add input__error'
                                    : (touched.city && !errors.city ? 'checkout__input__add input__success' : 'checkout__input__add') }),
                            errors.city && touched.city && React.createElement("label", { className: "error-message" }, errors.city),
                            React.createElement(formik_1.Field, { name: "street", type: "text", placeholder: "Ulice", className: (touched.street && errors.street)
                                    ? 'input__error'
                                    : (touched.street && !errors.street ? 'input__success' : '') }),
                            errors.street && touched.street && React.createElement("label", { className: "error-message" }, errors.street)),
                        React.createElement("div", { className: "checkout__input" },
                            React.createElement("p", null,
                                "PS\u010C",
                                React.createElement("span", null, "*")),
                            React.createElement(formik_1.Field, { name: "zipCode", type: "text", placeholder: "Po\u0161tovn\u00ED sm\u011Brovac\u00ED \u010D\u00EDslo", className: (touched.zipCode && errors.zipCode)
                                    ? 'input__error'
                                    : (touched.zipCode && !errors.zipCode ? 'input__success' : '') }),
                            errors.zipCode && touched.zipCode && React.createElement("label", { className: "error-message" }, errors.zipCode)),
                        React.createElement("div", { className: "row" },
                            React.createElement("div", { className: "col-lg-6" },
                                React.createElement("div", { className: "checkout__input" },
                                    React.createElement("p", null,
                                        "Telefonn\u00ED \u010D\u00EDslo",
                                        React.createElement("span", null, "*")),
                                    React.createElement(formik_1.Field, { name: "phoneNumber", type: "text", placeholder: "Telefonn\u00ED \u010D\u00EDslo", className: (touched.phoneNumber && errors.phoneNumber)
                                            ? 'input__error'
                                            : (touched.phoneNumber && !errors.phoneNumber ? 'input__success' : '') }),
                                    errors.phoneNumber && touched.phoneNumber && React.createElement("label", { className: "error-message" }, errors.phoneNumber))))),
                    React.createElement(react_bootstrap_1.Modal.Footer, null,
                        React.createElement("button", { type: "submit", className: "primary-btn" }, "Potvrdit"),
                        React.createElement("button", { type: "button", onClick: onCreateAddressModalClose, className: "danger-btn" }, "Zru\u0161it"))));
            }))));
}
exports.default = AddressFormModal;
//# sourceMappingURL=AddressFormModal.js.map