import React, {Component} from 'react';
import {observer} from 'mobx-react';
import {WeaRadioGroup, WeaLocaleProvider} from 'ecCom';
import classnames from 'classnames';

const getLabel = WeaLocaleProvider.getLabel;

@observer
export default class SearchGroup extends Component{
    render(){
        const {store} = this.props;
        const {radioGroupConfig, showRadioGroup} = store;
        const displayClassName = classnames({
            radioGroupShow: true,
            radioGroupHide: !showRadioGroup
        })
        const iconClassName = classnames({
            'icon-coms-down-001': !showRadioGroup,
            'icon-coms-up-001': showRadioGroup
        })

        const label = showRadioGroup ? getLabel('517204','隐藏条件') : getLabel('19496','显示条件');

        return (
            <div className='searchGroup'>
                <div className={displayClassName} onClick={() => store.showRadioGroup = !showRadioGroup}>
                    <span>{label}</span>
                    <span>
                        <i className={iconClassName} />
                    </span>
                </div>
                <div style={{display: showRadioGroup ? 'block' : 'none'}}>
                    <WeaRadioGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaRadioGroup@6w8eqc`} {...radioGroupConfig} />
                </div>
            </div>
        )
    }
}