import { useRef } from 'react'; import { Form, FormRow, FormInput, FormButtons, PasswordField, Button } from 'react-basics'; import useApi from 'hooks/useApi'; import useUser from 'hooks/useUser'; export default function PasswordEditForm({ onSave, onClose }) { const { post, useMutation } = useApi(); const { user } = useUser(); const { mutate, error, isLoading } = useMutation(data => post(`/accounts/${user.id}/change-password`, data), ); const ref = useRef(null); const handleSubmit = async data => { mutate(data, { onSuccess: async () => { onSave(); }, }); }; const samePassword = value => { if (value !== ref?.current?.getValues('newPassword')) { return "Passwords don't match"; } return true; }; return (
); }