index.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 '../../components/LinkToUser'
  7. export const ResultUserFind = ({text, userFind = [], handleCancel }) => {
  8. return (
  9. <div className="ResultUserFindMobile">
  10. {userFind ?
  11. userFind?.map(({ _id, login, avatar }) => (
  12. <LinkToUser
  13. _id={_id}
  14. login={login}
  15. avatar={avatar}
  16. size={50}
  17. padding={'10px'}
  18. font={'20px'}
  19. onClick={handleCancel}
  20. key={_id}
  21. />
  22. ))
  23. :
  24. <p> Not found by request "{text} "</p>
  25. }
  26. </div>
  27. )
  28. }
  29. const SearchUser = ({my_Id, onSearch, searchUser, onPageData }) => {
  30. // const [value, setSearch] = useState('')
  31. // const onSearchUser = onSearch(setSearch(value))
  32. const onSearchUser = (value) =>
  33. console.log('value ', value)&&
  34. onSearch(value)
  35. const { Search } = Input
  36. // console.log('value ', value)
  37. return (
  38. <>
  39. {/* <Popover
  40. placement="bottom"
  41. destroyTooltipOnHide={true}
  42. size="large"
  43. content={
  44. <ResultUserFind
  45. my_Id={my_Id}
  46. size={'20px'}
  47. onPageData={onPageData}
  48. userFind={searchUser}
  49. />
  50. }
  51. > */}
  52. <Search
  53. placeholder="Enter search user"
  54. allowClear
  55. prefix={<UserOutlined />}
  56. enterButton="Search"
  57. size="large"
  58. onSearch={onSearchUser}
  59. className="Search"
  60. />
  61. <div>
  62. <ResultUserFind
  63. text={value}
  64. my_Id={my_Id}
  65. size={'20px'}
  66. onPageData={onPageData}
  67. userFind={searchUser}
  68. />
  69. </div>
  70. {/* </Popover> */}
  71. </>
  72. )
  73. }
  74. export const CSearchMobileVersion = connect(
  75. (state) => ({
  76. aboutUser: state.userData?.aboutUser,
  77. searchUser: state.promise?.searchUser?.payload,
  78. my_Id: state.auth?.payload?.sub?.id || '',
  79. }),
  80. {
  81. onSearch: actionSearchUser,
  82. onPageData: actionFullProfilePageUserTypeSaga,
  83. },
  84. )(SearchUser)