﻿import React, { memo, Fragment } from 'react';
import { withRouter } from "react-router-dom";
import Botones from '../../../components/UI/botonera/headerBotones.js';
import Config from '../../../components/Util/constantes.js';
import TablaFiltro from '../../../components/UI/tablaFiltroShort/tablaFiltroShort.jsx';
import DatePicker from '../../../components/UI/dataPicker/dataPicker.jsx';
import TextArea from '../../../components/UI/textArea/textArea.jsx';
import CajaTexto from '../../../components/UI/cajaTexto/cajaTexto.jsx';
import ComboBox from '../../../components/UI/comboBox/combobox.jsx';
import Widget from './arbolDeptos.jsx';

function CargaCuponesInt(props) {

    return (
        <Fragment>
            <div className="col-md-12">
                <div className='row'>
                    <div className="col-md-6">
                        <h1>{props.titulo}</h1>
                    </div>
                    <div className="col-md-6 text-right">
                        <div className="acciones">
                            <Botones
                                botones={props.botones}
                            />
                        </div>
                    </div>
                </div>

                <div className="content">
                    <div className="content-box box-primary">

                        <div className="row">
                            <div className="col-md-6">

                                <div className="row">
                                    <CajaTexto col="12" id="Nombre" type="text" label={props.Datos.Nombre.attributes.label} value={props.Datos.Nombre.value} attributes={props.Datos.Nombre.attributes} onChangeInput={props.onChangeInput} />
                                </div>

                                <div className="row">
                                    <TextArea id='Descripcion' col='12' value={props.Datos.Descripcion.value} label={props.Datos.Descripcion.attributes.label} attributes={props.Datos.Descripcion.attributes} onChangeInput={props.onChangeInput} rows='3' />
                                </div>

                                <div className="row">
                                    <DatePicker id="fecMesAno" col="12" handleChange={props.onhandleChangeDate} value={props.Datos.fecMesAno.value} attributes={props.Datos.fecMesAno.attributes} label={props.Datos.fecMesAno.attributes.label} formatDate={Config.dateformat} />
                                </div>

                                <div className="row">
                                    <ComboBox id="selectedProveedor" col="12" attributes={props.Datos.Proveedor.attributes} value={props.selectedProveedor} label={props.Datos.Proveedor.attributes.label} datos={props.listaProveedores} onChange={props.handleselectProveedor} />
                                </div>

                            </div>
                            <div className="col-md-6">


                                <div className="form-group">

                                    <label htmlFor={"labelDeptos"}>{"Departamentos:"}</label>
                                    <div className="row">
                                        <Widget
                                            listaOrganigramaTree={props.listaOrganigramaTree}
                                            checked={props.checked}
                                            expanded={props.expanded}
                                            pruebaCheck={props.pruebaCheck}
                                            pruebaExp={props.pruebaExp}
                                        />
                                    </div>

                                </div>

                            </div>

                        </div>

                        <div className="row">
                            <div className="col-sm-12 col-md-12">
                                <div id="master-tabla" className="table-responsive  col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                    <TablaFiltro
                                        titulo={'Lista de Cargas de Cupones'}
                                        columnas={props.columnas}
                                        datos={props.listaDatos}
                                        keyField={props.id}
                                        modo={props.cellEdit}
                                        selectRow={props.selectRow}
                                        nombreCSV={props.nombreCSV}
                                        botones={[]}
                                        botonesLista={[]}
                                        busqueda={true}
                                    />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div className='d-none'>
                    <input type='file' id='ArchivoCarga' ref={props.hiddenFileInput} onChange={props.cargaArchivoExcel} />
                </div>
            </div>
        </Fragment>
    );
};

export default withRouter(memo(CargaCuponesInt)); 