import React,{Component} from 'react'

import { Form, Input, DatePicker,Row, Col,Button,Icon ,Select} from 'antd';

import {InputSize,Currency,COUNTRY} from "./Utils"

import TextArea from './ZTextArea'


const FormItem = Form.Item;
const Option = Select.Option

export default class T77B extends Component
{
    name='77B'
    desp = "Narrative"
    
    pattern = ""



    onChange=(val)=>{
        this.props.onValue([{s1:val},val])
    }

    render()
    {
       let value =this.props.value

        let mval = value && value.length? value[1] : ''
        let errmsg = value && value.length==3?value[2]:{}

        value = value && value.length? value[0] : {}
        return (<Row>
            <Col span={24}>
            <FormItem
                  help={errmsg.s1}
                 validateStatus={errmsg.s1?'error':null}
                >
                        
                        <TextArea type= "textarea" maxLength={3*35} cols={35} rows={3} style={{imeMode:'disabled'}} placeholder="Narrative" value={value.s1} onChange={(e)=>this.onChange(e.target.value)}/>
                </FormItem>
            
            </Col>
        </Row>)
    }

}


export  class T77Bbak extends Component
{

    name='77B'
    desp = "Regulatory Reporting"
    
    pattern = ""
    tno = -1

    keys=[1,2,3,4,5]

    onChange=(index,value)=>
    {
        let obj = {};
        if(!value)
            value = ""
        let objtemp =this.props.value
        
        objtemp = objtemp && objtemp.length? objtemp[0] : {}

        objtemp["s"+index] = value;

        this.keys.forEach(i=>{
            obj['s'+i] = objtemp['s'+i]
        });
        
        let mval = `${obj.s1}${obj.s2}`
        if(obj.s3)
            mval = mval +"//"+obj.s3
        if(obj.s4)
            mval = mval + "\r\n//" + obj.s4
        if(obj.s5)
            mval = mval + "\r\n//" + obj.s5       
        this.props.onValue([obj,mval])
    }

    render()
    {
        let value =this.props.value

        value = value && value.length? value[0] : {}
        return (<Row>
            <Col style={{"minWidth":'100px'}} span={5}>
                <FormItem
                    label="Code"
                    required
                >
                           <Select size={InputSize} 
                             showSearch
                             allowClear={true}
                            optionFilterProp="children"
                            notFoundContent="Wrong Code"
                             style={{ width: "100%",zIndex:99 }} placeholder="Code" value={value.s1} onChange={(val)=>this.onChange(1,val)}>
                                <Option  value="BENEFRES">BENEFRES</Option> 
                                <Option  value="ORDERRES">ORDERRES</Option>
                                
                            </Select>
                </FormItem>
            </Col>
            <Col style={{"minWidth":'100px'}} span={5}>
                <FormItem
                    label="Country Code"
                    required
                >
                           <Select  placeholder="Country Code"
                            showSearch
                            allowClear={true}
                            optionFilterProp="children"
                            notFoundContent="Wrong Code"
                             size={InputSize}  style={{ width: "100%",zIndex:99 }}  value={value.s2} onChange={(val)=>this.onChange(2,val)}>
                                
                                {
                                    COUNTRY.map(item=><Option key={item.code}  value={item.code}>{item.code+'-'+item.name}</Option>)
                                }
                            </Select>
                </FormItem>
            </Col>
            <Col span={14}>
                <FormItem
                 label="Narrative"  
                 
                >
                        
                        <Input addonBefore="//"  type="text" maxLength={23} style={{imeMode:'disabled'}} value={value.s3} onChange={(e)=>this.onChange(3,e.target.value)} placeholder="Narrative"/>
                </FormItem>
            </Col>
            <Row>
                <FormItem
                 
                >
                        
                        <Input addonBefore="//"  type="text" maxLength={33} style={{imeMode:'disabled'}} value={value.s4} onChange={(e)=>this.onChange(4,e.target.value)} placeholder="Narrative"/>
                </FormItem>
            </Row>
             <Row>
                <FormItem
                 
                >
                        
                        <Input addonBefore="//"  type="text" maxLength={33} style={{imeMode:'disabled'}}  value={value.s5} onChange={(e)=>this.onChange(5,e.target.value)} placeholder="Narrative"/>
                </FormItem>
            </Row>
             
        </Row>)
    }
}