RegisterForm.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React, { useState } from 'react'
  2. import { connect } from 'react-redux'
  3. import { Button, Input, Checkbox, Form, Row, Col } from 'antd'
  4. import { Link } from 'react-router-dom'
  5. import { message } from 'antd'
  6. import { useEffect } from 'react'
  7. import { ImportOutlined } from '@ant-design/icons'
  8. import {
  9. actionRegisterTypeSaga,
  10. } from '../../redux/saga'
  11. import InitialForm from './InitialForm'
  12. import { actionClearPromiseForName } from '../../actions'
  13. const RegisterForm = ({ onLogin, children, register,onClearPromise }) => {
  14. useEffect(() => {
  15. if (register?.status === 'FULFILLED' && register?.payload === null) {
  16. message.error({
  17. content: 'This login is already in the database',
  18. style: {
  19. marginTop: '80px',
  20. },
  21. })
  22. &&onClearPromise("register")
  23. }
  24. }, [register])
  25. return (
  26. <InitialForm onLogin={onLogin}>
  27. {"Register"}
  28. </InitialForm>
  29. )
  30. }
  31. export const CRegisterForm = connect(
  32. (state) => ({
  33. children: `Register`,
  34. register: state.promise?.register,
  35. }),
  36. {
  37. onLogin: actionRegisterTypeSaga,
  38. onClearPromise:actionClearPromiseForName
  39. },
  40. )(RegisterForm)