ResetPassword.tsx 871 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { useMutation } from '@apollo/react-hooks'
  2. import { USER_RESET_PASSWORD } from './graphql'
  3. import { useFormHandler, TextInput } from '../form/forms'
  4. import { FormEvent } from 'react'
  5. const initialValues = {
  6. email: '',
  7. password: ''
  8. }
  9. const ResetPassword = () => {
  10. const [login, { loading, error }] = useMutation(USER_RESET_PASSWORD)
  11. const { inputProps } = useFormHandler(initialValues)
  12. return (
  13. <form onSubmit={async (event: FormEvent) => {
  14. event.preventDefault()
  15. try {
  16. const data = await login()
  17. console.log(data)
  18. } catch (error) {
  19. console.log(error)
  20. }
  21. }}>
  22. <TextInput label='Email' {...inputProps('email')} />
  23. <TextInput label='Password' {...inputProps('password')} />
  24. <button type='submit' disabled={loading}>Login!</button>
  25. </form>
  26. )
  27. }
  28. export default ResetPassword