templates/Contact/index.html.twig line 1

Open in your IDE?
  1. {% extends "base.html.twig" %}
  2. {% block stylesheets %}
  3.     <style>
  4.         body {
  5.             background-color: #272727;
  6.         }
  7.         .headerImg {
  8.             background-image: url("{{ asset('assets/img/Catalog/HeaderImg.jpeg')}}");
  9.             background-size: cover;
  10.             background-position: center;
  11.             height: 500px;
  12.             position: relative;
  13.         }
  14.         .top-25 {
  15.             top: 250px;
  16.         }
  17.         .btn-send-message {
  18.             background-color: #ffffff;
  19.             border: 1px solid rgb(255, 255, 255, 0.3);
  20.             color: rgb(0, 0, 0, 0.7);
  21.             padding: 0.5rem 2rem;
  22.             text-decoration: none;
  23.         }
  24.         .form-control {
  25.             background-color: transparent;
  26.             border: 1px solid rgb(255, 255, 255, 0.3);
  27.             color: rgb(255, 255, 255, 0.7);
  28.             border-radius: 0;
  29.         }
  30.         .form-control:focus {
  31.             background-color: transparent;
  32.             border: 1px solid rgb(255, 255, 255, 0.7);
  33.             color: rgb(255, 255, 255, 0.7);
  34.             box-shadow: none;
  35.         }
  36.         .form-select {
  37.             background-color: transparent;
  38.             border: 1px solid rgb(255, 255, 255, 0.3);
  39.             color: rgb(255, 255, 255, 0.7);
  40.             border-radius: 0;
  41.         }
  42.         .form-select:focus {
  43.             background-color: transparent;
  44.             border: 1px solid rgb(255, 255, 255, 0.7);
  45.             color: rgb(255, 255, 255, 0.7);
  46.             box-shadow: none;
  47.         }
  48.         option {
  49.             background-color: #040404;
  50.             color: rgb(255, 255, 255, 0.7);
  51.         }
  52.         .title-header {
  53.             font-weight: bold;
  54.             text-transform: uppercase;
  55.             font-size: 50px;
  56.         }
  57.         .subtitle-header {
  58.             font-weight: 200;
  59.             font-size: 25px;
  60.             line-height: 25px;
  61.             display: block;
  62.             margin: 0 auto;
  63.             max-width: 500px;
  64.         }
  65.     </style>
  66. {% endblock %}
  67. {% block body %}
  68. <div id="contact_us_form_vue">
  69.     {# ------------------------------------------ Header ------------------------------------------ #}
  70.     <section class="headerImg">
  71.         <div class="position-absolute top-25 start-50 translate-middle text-center">
  72.             <h1 class="text-white title-header">Contacto</h1>
  73.             <h3 class="text-white subtitle-header">¿Listo para cambiar tu vida? Llena el siguiente formulario y uno de nuestros colaboradores se pondrá en contacto contigo.</h3>
  74.         </div>
  75.     </section>
  76.     {# ------------------------------------------ Header ------------------------------------------ #}
  77.     
  78.     {# ------------------------------------------ Form ------------------------------------------ #}
  79.     <section class="container my-5">
  80.         <div class="row">
  81.             <div class="col-md-12">
  82.                 {# <form> #}
  83.                     <div class="row justify-content-center align-items-center g-2">
  84.                         <div class="col-md-3 mb-3">
  85.                             <label for="name" class="form-label text-white">Nombre *</label>
  86.                             <input placeholder="Nombre" v-model="emailData.name" type="text" class="form-control" id="name" aria-describedby="nameHelp">
  87.                             <span v-if="emailErrors.nameError" class="text-danger">${ emailErrors.nameErrorMessage }</span>
  88.                         </div>
  89.                         <div class="col-md-3 mb-3">
  90.                             <label for="email" class="form-label text-white">Correo electrónico *</label>
  91.                             <input placeholder="Correo electrónico" v-model="emailData.email" type="email" class="form-control" id="email" aria-describedby="emailHelp">
  92.                             <span v-if="emailErrors.emailError" class="text-danger">${ emailErrors.emailErrorMessage }</span>
  93.                         </div>
  94.                     </div>
  95.                     <div class="row justify-content-center align-items-center g-2">
  96.                         <div class="col-md-3 mb-3">
  97.                             <label for="motive" class="form-label text-white">Motivo *</label>
  98.                             <select id="reason-select" class="form-select" aria-label="Selecciona el motivo">
  99.                                 <option selected disabled hidden>Selecciona el motivo</option>
  100.                                 <option value="DOUBTS">Dudas generales</option>
  101.                                 <option value="CONSULT_PRODUCT">Consultar producto</option>
  102.                                 <option value="OTHERS">Otros</option>
  103.                             </select>
  104.                             <span v-if="emailErrors.reasonError" class="text-danger">${ emailErrors.reasonErrorMessage }</span>
  105.                         </div>
  106.                         <div class="col-md-3 mb-3">
  107.                             <label for="email" class="form-label text-white">Estado *</label>
  108.                             <select id="state-select" class="form-select" aria-label="Default select example">
  109.                                 <option selected disabled hidden>Selecciona tu estado</option>
  110.                                 <option value="AGUASCALIENTES">Aguascalientes</option>
  111.                                 <option value="CHIPAS">Chiapas</option>
  112.                                 <option value="CIUDAD DE MEXICO">Ciudad de México</option>
  113.                                 <option value="GUANAJUATO">Guanajuato</option>
  114.                                 <option value="HIDALGO">Hidalgo</option>
  115.                                 <option value="JALISCO">Jalisco</option>
  116.                                 <option value="MEXICO">México</option>
  117.                                 <option value="MORELOS">Morelos</option>
  118.                                 <option value="NUEVO LEON">Nuevo León</option>
  119.                                 <option value="OAXACA">Oaxaca</option>
  120.                                 <option value="PUEBLA">Puebla</option>
  121.                                 <option value="QUERETARO">Querétaro</option>
  122.                                 <option value="TLAXCALA">Tlaxcala</option>
  123.                             </select>
  124.                             <span v-if="emailErrors.stateError" class="text-danger">${ emailErrors.stateErrorMessage }</span>
  125.                         </div>
  126.                     </div>
  127.                     <div class="row justify-content-center align-items-center g-2">
  128.                         <div class="col-md-6 mb-3">
  129.                             <label for="message" class="form-label text-white">Mensaje *</label>
  130.                             <textarea v-model="emailData.message" class="form-control" id="message" rows="3"></textarea>
  131.                             <span v-if="emailErrors.messageError" class="text-danger">${ emailErrors.messageErrorMessage }</span>
  132.                         </div>
  133.                     </div>
  134.                     <div class="row justify-content-center align-items-center g-2">
  135.                         <div class="col-md-3 mb-3 text-center">
  136.                             <button @click="sendEmailContact" id="btn-send-message" class="btn-send-message fw-bolder" 
  137.                                 :disabled="sendingMail">${ sendingMail ? 'Enviando' : 'Enviar' } <i v-if="sendingMail" class="fa-solid fa-spinner fa-spin-pulse"></i></i></button>
  138.                         </div>
  139.                     </div>
  140.                 {# </form> #}
  141.             </div>
  142.         </div>
  143.     </section>
  144. </div>
  145.     {# ------------------------------------------ Form ------------------------------------------ #}
  146. {% endblock %}
  147. {% block javascripts %}
  148. {% if app.environment == 'dev' %}
  149.     <script src="{{ asset('assets/vue/vue.js') }}"></script>
  150. {% else %}
  151.     <script src="{{ asset('assets/vue/vue.min.js') }}"></script>
  152. {% endif %}
  153. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  154. <script>
  155.     let contactUsFormVue = new Vue({
  156.         el: '#contact_us_form_vue',
  157.         delimiters: ['${', '}'],
  158.         data: {
  159.             emailData: {
  160.                 name: '',
  161.                 email: '',
  162.                 messsage: '',
  163.                 reason: '',
  164.                 state: ''
  165.             },
  166.             emailErrors: {
  167.                 nameError: false,
  168.                 nameErrorMessage: '',
  169.                 emailError: false,
  170.                 emailErrorMessage: '',
  171.                 messageError: false,
  172.                 messageErrorMessage: '',
  173.                 reasonError: false,
  174.                 reasonErrorMessage: '',
  175.                 stateError: false,
  176.                 stateErrorMessage: ''
  177.             },
  178.             sendingMail: false
  179.         },
  180.         methods: {
  181.             sendEmailContact() {
  182.                 let $this = this;
  183.                 if ($this.validateEmailData()) {
  184.                     $this.sendingMail = true;
  185.                     $.ajax({
  186.                     url: "{{ path('sendContactUsEmail') }}",
  187.                     data: {
  188.                         name: $this.emailData.name,
  189.                         email: $this.emailData.email,
  190.                         message: $this.emailData.message,
  191.                         reason: $('#reason-select').val(),
  192.                         state: $('#state-select').val()
  193.                     },
  194.                     success(response) {
  195.                             if (response.code == 'OK') {
  196.                                 $this.emailErrors.nameError = false;
  197.                                 $this.emailErrors.emailError = false;
  198.                                 $this.emailErrors.messageError = false;
  199.                                 $this.emailErrors.reasonError = false;
  200.                                 $this.emailErrors.stateError = false;
  201.                                 $this.emailData.name = '';
  202.                                 $this.emailData.email = '';
  203.                                 $this.emailData.message = '';
  204.                                 $('#reason-select').val(null).trigger('change');
  205.                                 $('#state-select').val(null).trigger('change');
  206.                                 Swal.fire({
  207.                                     title: 'Correo enviado',
  208.                                     html: 'Se han enviado tus datos a DIALVI, nuestros agentes de soporte se pondran en contacto contigo',
  209.                                     icon: 'success',
  210.                                     showCancelButton: false,
  211.                                     confirmButtonText: 'Entendido'
  212.                                 });
  213.                             } else if (response.code == 'EME') {
  214.                                 Swal.fire({
  215.                                     title: 'Información faltante',
  216.                                     html: 'Hay información requerida que no se ha enviado, revise si los campos fueron llenados correctamente',
  217.                                     icon: 'error',
  218.                                     showCancelButton: false,
  219.                                     confirmButtonText: 'Entendido'
  220.                                 });
  221.                             } else if (response.code == 'NOK') {
  222.                                 Swal.fire({
  223.                                     title: 'Envio fallido',
  224.                                     html: 'No se ha podido enviar la información de contacto, por favor intentelo mas tarde.',
  225.                                     icon: 'error',
  226.                                     showCancelButton: false,
  227.                                     confirmButtonText: 'Entendido'
  228.                                 });
  229.                             }
  230.                         },
  231.                         complete: () => {
  232.                             $this.sendingMail = false;
  233.                         }
  234.                     });
  235.                 }
  236.             },
  237.             validateEmailData() {
  238.                 let validation = true;
  239.                 let $this = this;
  240.                 $this.emailErrors.nameError = false;
  241.                 $this.emailErrors.emailError = false;
  242.                 $this.emailErrors.messageError = false;
  243.                 $this.emailErrors.reasonError = false;
  244.                 $this.emailErrors.stateError = false;
  245.                 if ($this.emailData.name ? $this.emailData.name.trim() == '' : true) {
  246.                     validation = false;
  247.                     $this.emailErrors.nameError = true;
  248.                     $this.emailErrors.nameErrorMessage = 'Ingrese su nombre.';
  249.                 }
  250.                 if ($this.emailData.email ? $this.emailData.email.trim() == '' : true) {
  251.                     validation = false;
  252.                     $this.emailErrors.emailError = true;
  253.                     $this.emailErrors.emailErrorMessage = 'Ingrese su correo electrónico.';
  254.                 }
  255.                 if ($this.emailData.message ? $this.emailData.message.trim() == '' : true) {
  256.                     validation = false;
  257.                     $this.emailErrors.messageError = true;
  258.                     $this.emailErrors.messageErrorMessage = 'Ingrese el mensaje.';
  259.                 }
  260.                 if (!$('#reason-select').val()) {
  261.                     validation = false;
  262.                     $this.emailErrors.reasonError = true;
  263.                     $this.emailErrors.reasonErrorMessage = 'Selecciona la razón de tu correo.';
  264.                 }
  265.                 if (!$('#state-select').val()) {
  266.                     validation = false;
  267.                     $this.emailErrors.stateError = true;
  268.                     $this.emailErrors.stateErrorMessage = 'Selecciona tu estado.';
  269.                 }
  270.                 return validation;
  271.             }
  272.         }
  273.     });
  274. </script>
  275. {% endblock %}