import { useRef } from 'react'; import { Form, FormInput, FormButtons, PasswordField, Button } from 'react-basics'; import { useApi } from 'next-basics'; import { useMutation } from '@tanstack/react-query'; import { getAuthToken } from 'lib/client'; import styles from './Form.module.css'; export default function PasswordEditForm({ onSave, onClose }) { const { post } = useApi(getAuthToken()); const { mutate, error, isLoading } = useMutation(data => post('/account/change-password', data)); const ref = useRef(null); const handleSubmit = async data => { mutate(data, { onSuccess: async () => { onSave(); }, }); }; const samePassword = value => { if (value !== ref?.current?.getValues('new_password')) { return "Passwords don't match"; } return true; }; return ( <>
); }