index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. {typeof userFind === 'undefined'
  12. ?
  13. null :
  14. userFind?.length > 0 ?
  15. userFind?.map(({ _id, login, avatar }) => (
  16. <LinkToUser
  17. _id={_id}
  18. login={login}
  19. avatar={avatar}
  20. size={50}
  21. padding={'10px'}
  22. font={'20px'}
  23. onClick={handleCancel}
  24. key={_id}
  25. />
  26. ))
  27. :
  28. <p style={{fontSize:'16px',textAlign:'center'}}> Not found by request </p>
  29. }
  30. </div>
  31. )
  32. }
  33. const SearchUser = ({my_Id,onSearch,actionClear, searchUser, onPageData }) => {
  34. const onSearchUser = (value) =>
  35. onSearch(value)
  36. const { Search } = Input
  37. return (
  38. <>
  39. <Search
  40. placeholder="Enter search user"
  41. allowClear={actionClear}
  42. prefix={<UserOutlined />}
  43. enterButton="Search"
  44. size="large"
  45. onSearch={onSearchUser}
  46. className="Search"
  47. />
  48. <div>
  49. <ResultUserFind
  50. my_Id={my_Id}
  51. size={'20px'}
  52. onPageData={onPageData}
  53. userFind={searchUser}
  54. />
  55. </div>
  56. {/* </Popover> */}
  57. </>
  58. )
  59. }
  60. export const CSearchMobileVersion = connect(
  61. (state) => ({
  62. aboutUser: state.userData?.aboutUser,
  63. searchUser: state.promise?.searchUser?.payload,
  64. my_Id: state.auth?.payload?.sub?.id || '',
  65. }),
  66. {
  67. onSearch: actionSearchSaga,
  68. actionClear:actionClearSearchType,
  69. onPageData: actionFullProfilePageUserTypeSaga,
  70. },
  71. )(SearchUser)