Search_Users.jsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { Link } from 'react-router-dom'
  2. import { connect } from 'react-redux'
  3. import { Row, Col,Avatar, Input, Popover } from 'antd'
  4. import user from '../materials/user.png'
  5. import { actionSearchUser } from '../actions/query/searchUserQuery'
  6. import {UserOutlined,SearchOutlined } from '@ant-design/icons'
  7. import { actionFullProfilePageUserTypeSaga } from '../actions/typeSaga/userTypesSaga'
  8. import LinkToUser from './LinkToUser'
  9. export const ResultUserFind = ({
  10. userFind = [],
  11. handleCancel,
  12. }) => {
  13. console.log('user find', userFind)
  14. return (
  15. <div className="ResultUserFind">
  16. {userFind?.map(({ _id, login, avatar }) => (
  17. <LinkToUser _id={_id} login={login}
  18. avatar={avatar} size={40} padding={'0px'}
  19. onClick={handleCancel} key={_id} />
  20. ))}
  21. </div>
  22. )
  23. }
  24. const SearchUser = ({ my_Id, onSearch, searchUser, onPageData }) => {
  25. const onSearchUser = (value) => onSearch(value)
  26. const { Search } = Input
  27. return (
  28. <>
  29. <Popover
  30. placement="bottom"
  31. destroyTooltipOnHide={true}
  32. size="large"
  33. content={
  34. <ResultUserFind
  35. my_Id={my_Id}
  36. size={'20px'}
  37. onPageData={onPageData}
  38. userFind={searchUser}
  39. />
  40. }
  41. >
  42. <Search
  43. // style={{ width: '25%' }}
  44. placeholder="Enter search user"
  45. allowClear
  46. prefix={<UserOutlined />}
  47. enterButton="Search"
  48. size="large"
  49. onSearch={onSearchUser}
  50. />
  51. </Popover>
  52. </>
  53. )
  54. }
  55. export const CSearch = connect(
  56. (state) => ({
  57. aboutUser: state.userData?.aboutUser,
  58. searchUser: state.promise?.searchUser?.payload,
  59. my_Id: state.auth?.payload?.sub?.id || '',
  60. }),
  61. {
  62. onSearch: actionSearchUser,
  63. onPageData: actionFullProfilePageUserTypeSaga,
  64. },
  65. )(SearchUser)