import React,{Component} from 'react'
import TextArea from './ZTextArea'

import { Form, Input, DatePicker,TimePicker,Row, Col,Button,Icon ,Select} from 'antd';
import {InputSize,Currency,FormatAmount} from "./Utils"

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

export default class T35B extends Component
{

    name='35B'
    desp = "Identification of Financial Instrument"
    
    pattern = "[ISIN1!e12!c][4*35x]"
    tno = -1


    keys=[2,3]
    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 = ""
        if(obj.s2)
        mval = "ISIN "+`${obj.s2}`
        if(obj.s3)
        mval = mval + `\r\n${obj.s3}`

        this.props.onValue([obj,mval])
    }

    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 (
        <div>    
        <Row>

           <Col  style={{"minWidth":'200px'}} span={3}>
                <FormItem
                 label="Identification of Instrument"  
                 required={this.props.status=='M' || mval?'required':null}
                  help={errmsg.s2}
                    validateStatus={errmsg.s2?'error':null}
                >                       
                        <Input  value={value.s2} onChange={e=>this.onChange(2,e.target.value)}  maxLength={12} style={{imeMode:'disabled'}} placeholder="Identification of Instrument"/>
                </FormItem>
            </Col>

        </Row>
        <Row>
            <Col span={24}>
                <FormItem
                label="Description of Instrument"  
                required={this.props.status=='M' || mval?'required':null}
                  help={errmsg.s3}
                     validateStatus={errmsg.s3?'error':null}
                >
                        
                        <TextArea type= "textarea" maxLength={4*35} cols={35} rows={4} style={{imeMode:'disabled'}} placeholder="Description of Instrument" value={value.s3} onChange={(e)=>this.onChange(3,e.target.value)}/>
                </FormItem>
            </Col>
        </Row>
        
        </div>
        )
    }
}