import React, { useState } from 'react';
import { FormattedMessage } from 'react-intl';
import { Formik, Form, Field } from 'formik';
import { post } from 'lib/web';
import Button from 'components/common/Button';
import FormLayout, {
FormButtons,
FormError,
FormMessage,
FormRow,
} from 'components/layout/FormLayout';
const initialValues = {
current_password: '',
new_password: '',
confirm_password: '',
};
const validate = ({ current_password, new_password, confirm_password }) => {
const errors = {};
if (!current_password) {
errors.current_password = ;
}
if (!new_password) {
errors.new_password = ;
}
if (!confirm_password) {
errors.confirm_password = ;
} else if (new_password !== confirm_password) {
errors.confirm_password = (
);
}
return errors;
};
export default function ChangePasswordForm({ values, onSave, onClose }) {
const [message, setMessage] = useState();
const handleSubmit = async values => {
const response = await post(`/api/account/password`, values);
if (typeof response !== 'string') {
onSave();
} else {
setMessage(
response || (
),
);
}
};
return (
{() => (
)}
);
}