index.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { connect } from 'react-redux'
  2. import { Input, Popover } from 'antd'
  3. import { actionSearchUser } from '../../actions/query/searchUserQuery'
  4. import { UserOutlined } from '@ant-design/icons'
  5. import {actionSearchSaga,actionClearSearchType} from '../../actions/types/searchType'
  6. import { actionFullProfilePageUserTypeSaga } from '../../actions/typeSaga/userTypesSaga'
  7. import LinkToUser from '../../components/LinkToUser'
  8. export const ResultUserFind = ({ userFind, handleCancel }) => {
  9. return (
  10. <div className="ResultUserFindMobile">
  11. {console.log('userfind ', userFind)}
  12. {typeof userFind === 'undefined'
  13. ?
  14. null :
  15. userFind?.length > 0 ?
  16. userFind?.map(({ _id, login, avatar }) => (
  17. <LinkToUser
  18. _id={_id}
  19. login={login}
  20. avatar={avatar}
  21. size={50}
  22. padding={'10px'}
  23. font={'20px'}
  24. onClick={handleCancel}
  25. key={_id}
  26. />
  27. ))
  28. :
  29. <p style={{fontSize:'16px', textAlign:'center'}}> Not found by request </p>
  30. }
  31. </div>
  32. )
  33. }
  34. const SearchUser = ({my_Id,onSearch,actionClear, searchUser, onPageData }) => {
  35. const onSearchUser = (value) =>
  36. onSearch(value)
  37. const { Search } = Input
  38. return (
  39. <>
  40. <Search
  41. placeholder="Enter search user"
  42. allowClear={actionClear}
  43. prefix={<UserOutlined />}
  44. enterButton="Search"
  45. size="large"
  46. onSearch={onSearchUser}
  47. className="Search"
  48. />
  49. <div>
  50. <ResultUserFind
  51. my_Id={my_Id}
  52. size={'20px'}
  53. onPageData={onPageData}
  54. userFind={searchUser}
  55. />
  56. </div>
  57. {/* </Popover> */}
  58. </>
  59. )
  60. }
  61. export const CSearchMobileVersion = connect(
  62. (state) => ({
  63. aboutUser: state.userData?.aboutUser,
  64. searchUser: state.promise?.searchUser?.payload,
  65. my_Id: state.auth?.payload?.sub?.id || '',
  66. }),
  67. {
  68. onSearch: actionSearchSaga,
  69. actionClear:actionClearSearchType,
  70. onPageData: actionFullProfilePageUserTypeSaga,
  71. },
  72. )(SearchUser)