inputSearchGood.js 968 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Input, Button } from 'antd';
  2. import { SearchOutlined } from '@ant-design/icons';
  3. import { useEffect, useState } from 'react';
  4. import { connect } from 'react-redux';
  5. import {Link} from 'react-router-dom';
  6. const InputSearchG = ({nick}) => {
  7. const [inputValue, setInputValue] = useState('');
  8. const [user, setUser] = useState(nick);
  9. useEffect(() => {
  10. if(nick && nick.acl && nick.acl.includes('admin')) {
  11. setUser('admin')
  12. }
  13. }, [nick])
  14. return (
  15. < >
  16. <Input placeholder="Найти товар " value={inputValue} size="middle" style={{ width: '40%' }} onChange={(e) => setInputValue(e.target.value)}/>
  17. <Link to={`/search/${inputValue}`}><Button icon={<SearchOutlined />} onClick={() => setInputValue('')}/></Link>
  18. </>
  19. )
  20. }
  21. const mapStateToProps = (state) => ({
  22. nick: state.auth.payload?.sub || '',
  23. })
  24. const InputSearchGood = connect(mapStateToProps)(InputSearchG);
  25. export default InputSearchGood;