LoginForm.jsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. actionClearDataLogoutTypeSaga,
  10. actionLoginTypeSaga,
  11. actionRegisterTypeSaga,
  12. } from '../../redux/saga'
  13. import InitialForm from './InitialForm'
  14. const LoginForm = ({ onLogin, children, auth }) => {
  15. useEffect(() => {
  16. if (auth?.status === 'FULFILLED' && auth?.payload === null) {
  17. message.error({
  18. content: 'You entered wrong login or password',
  19. style: {
  20. marginTop: '80px',
  21. },
  22. })
  23. }
  24. }, [auth])
  25. return (
  26. <InitialForm onLogin={onLogin}>
  27. {"Sign In"}
  28. </InitialForm>
  29. )
  30. }
  31. export const CLoginForm = connect(
  32. (state) => ({
  33. children: `Sign In`,
  34. auth: state.promise?.auth,
  35. }),
  36. {
  37. onLogin: actionLoginTypeSaga,
  38. },
  39. )(LoginForm)