import { useRef } from 'react'; import { Form, FormRow, FormInput, FormButtons, PasswordField, Button } from 'react-basics'; import { useIntl } from 'react-intl'; import useApi from 'hooks/useApi'; import { labels, messages } from 'components/messages'; export default function PasswordEditForm({ onSave, onClose }) { const { formatMessage } = useIntl(); const { post, useMutation } = useApi(); const { mutate, error, isLoading } = useMutation(data => post('/me/password', data)); const ref = useRef(null); const handleSubmit = async data => { mutate(data, { onSuccess: async () => { onSave(); onClose(); }, }); }; const samePassword = value => { if (value !== ref?.current?.getValues('newPassword')) { return formatMessage(messages.noMatchPassword); } return true; }; return (
); }