import React, { Component } from "react"; import { withRouter, } from "react-router-dom"; import { Row, Col, } from 'react-bootstrap' class WhatsappPage extends Component { constructor(props) { super(props); this.state = { inputTel: '', inputAlias: '', inputMensaje: 'Hola ¿Me podrías dar mas información?', editWhatsappStatus: false, indexInput: 0 } } componentDidMount() { } onChangeParentData(opt, event) { const { arrDatos } = this.props.initState const { whatsapp } = arrDatos if(opt === 'titulo') whatsapp.titulo = event.target.value; this.props.initsetState({ arrDatos }) } onAdd() { const { arrDatos } = this.props.initState const { whatsapp } = arrDatos const { inputTel, inputAlias, inputMensaje } = this.state if(inputTel === '' || inputAlias === '' || inputMensaje === '') { alert('Datos incompletos') return false } whatsapp.whatsapp.push({ whatsapp: inputTel, titulo: inputAlias, mensaje: inputMensaje, }) this.props.initsetState({ arrDatos }) this.setState({ inputTel: '', inputAlias: '', inputMensaje: '', }) this.checkMarkValues(); } onDeleteEmail(index) { let { arrDatos } = this.props.initState let { whatsapp } = arrDatos whatsapp.whatsapp.splice(index, 1); this.props.initsetState({ arrDatos }) } onEditWhatsapp(index){ if(this.state.editWhatsappStatus==false){ this.state.indexInput = index this.setState({ editWhatsappStatus: true }) }else{ this.setState({ editWhatsappStatus: false }) } } checkMarkValues(){ const { arrDatos,arrCheck } = this.props.initState const { email,telefono,whatsapp } = arrDatos if(email.email.length > 0 && telefono.telefono.length > 0 && whatsapp.whatsapp.length > 0){ arrCheck[4].checkMark = true; }else{ arrCheck[4].checkMark = false; } } makeList(item, index) { const { arrDatos } = this.props.initState const { whatsapp } = arrDatos return (
{item.titulo}
) }{item.whatsapp}
) } { ( this.state.editWhatsappStatus==true && this.state.indexInput==index ? { whatsapp.whatsapp[index]['mensaje'] = event.target.value; this.props.initsetState({ arrDatos }); }} value={item.mensaje} /> :{item.mensaje}
) }Leyenda del Botón
Alias
Mensaje
Número de teléfono *
{ this.onAdd() } } >Agregar teléfono