Search_Users.jsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 { actionFullProfilePageUserTypeSaga } from '../actions/typeSaga/userTypesSaga'
  6. import LinkToUser from './LinkToUser'
  7. export const ResultUserFind = ({ userFind = [], handleCancel }) => {
  8. return (
  9. <div className="ResultUserFind">
  10. {userFind?.map(({ _id, login, avatar }) => (
  11. <LinkToUser
  12. _id={_id}
  13. login={login}
  14. avatar={avatar}
  15. padding={'5px'}
  16. onClick={handleCancel}
  17. key={_id}
  18. />
  19. ))}
  20. </div>
  21. )
  22. }
  23. const SearchUser = ({ my_Id, onSearch, searchUser, onPageData }) => {
  24. const onSearchUser = (value) => onSearch(value)
  25. const { Search } = Input
  26. return (
  27. <>
  28. <Popover
  29. placement="bottom"
  30. destroyTooltipOnHide={true}
  31. size="large"
  32. content={
  33. <ResultUserFind
  34. my_Id={my_Id}
  35. size={'20px'}
  36. onPageData={onPageData}
  37. userFind={searchUser}
  38. />
  39. }
  40. >
  41. <Search
  42. placeholder="Enter search user"
  43. allowClear
  44. prefix={<UserOutlined />}
  45. enterButton="Search"
  46. size="large"
  47. onSearch={onSearchUser}
  48. />
  49. </Popover>
  50. </>
  51. )
  52. }
  53. export const CSearch = connect(
  54. (state) => ({
  55. aboutUser: state.userData?.aboutUser,
  56. searchUser: state.promise?.searchUser?.payload,
  57. my_Id: state.auth?.payload?.sub?.id || '',
  58. }),
  59. {
  60. onSearch: actionSearchUser,
  61. onPageData: actionFullProfilePageUserTypeSaga,
  62. },
  63. )(SearchUser)