Просмотр исходного кода

show next number in verify, remake mails

Erwin Jacimino 8 месяцев назад
Родитель
Сommit
3fdf546c31
3 измененных файлов с 119 добавлено и 62 удалено
  1. 32 49
      config/mails.py
  2. 1 1
      public/register/app.js
  3. 86 12
      public/verify.html

+ 32 - 49
config/mails.py

@@ -4,13 +4,13 @@ from config.settings import APP_NAME, CURRENT_URL
 REGISTER_MAIL = {
     "subject": "Bienvenido a " + APP_NAME + " - Confirma tu registro",
     "body": """
-<html>
+    <html>
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>¡Bienvenido a {app_name}!</title>
     <style>
-        body {{
+              body {{
             margin: 0;
             padding: 0;
             font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
@@ -69,6 +69,8 @@ REGISTER_MAIL = {
         }}
         
         .benefits-section {{
+            text-align: center;
+          gap: 20px;
             background-color: #f9fafb;
             border-radius: 8px;
             padding: 24px;
@@ -116,15 +118,11 @@ REGISTER_MAIL = {
         }}
         
         .verification-icon {{
-            font-size: 48px;
-            margin: 16px 0;
-            border: 3px solid white;
-            border-radius: 50%;
-            padding: 20px;
-            display: inline-block;
-            width: 80px;
-            height: 80px;
-            line-height: 80px;
+            margin: 32px auto;
+            width: 100px;
+            height: 100px;
+            display: block;
+
         }}
         
         .verification-description {{
@@ -132,6 +130,11 @@ REGISTER_MAIL = {
             margin: 16px 0;
             opacity: 0.95;
         }}
+        .verification-description-2 {{
+            font-size: 18px;
+            margin-top: 24px;
+            opacity: 0.95;
+        }}
         
         .cta-button {{
             background-color: white;
@@ -183,7 +186,7 @@ REGISTER_MAIL = {
             border-bottom: 2px solid #101419;
             padding-bottom: 4px;
         }}
-        
+      
         .footer {{
             background-color: #f9fafb;
             padding: 24px 32px;
@@ -197,25 +200,6 @@ REGISTER_MAIL = {
             margin: 0;
             line-height: 1.5;
         }}
-        
-        @media (max-width: 600px) {{
-            .email-container {{
-                margin: 0;
-                border-radius: 0;
-            }}
-            
-            .header, .content {{
-                padding: 24px 16px;
-            }}
-            
-            .verification-icon {{
-                font-size: 36px;
-                padding: 16px;
-                width: 60px;
-                height: 60px;
-                line-height: 60px;
-            }}
-        }}
     </style>
 </head>
 <body>
@@ -231,40 +215,39 @@ REGISTER_MAIL = {
             <div class="content">
                 <!-- Welcome Message -->
                 <div class="welcome-message">
-                    <h2>Te damos la bienvenida a {app_name}</h2>
-                    <p>Tu registro ha sido exitoso. <br>Estamos emocionados de tenerte con nosotros. Para completar tu registro, necesitas crear tu PIN de seguridad.</p>
-                </div>
-                
-                <!-- Benefits Section -->
-                <div class="benefits-section">
-                    <h3 class="benefits-title">¿Qué puedes hacer con {app_name}?</h3>
-                    <ul class="benefits-list">
-                        <li>Realizar pedidos de forma rápida y sencilla</li>
-                        <li>Acceder a promociones exclusivas</li>
-                        <li>Disfrutar de una experiencia personalizada</li>
-                        <li>Usar nuestra inteligencia artificial</li>
-                    </ul>
+                    <h2>Necesitas crear tu pin de seguridad</h2>
                 </div>
-                
                 <!-- Verification Section -->
                 <div class="verification-section">
                     <div class="verification-description">¡Solo falta un paso más!</div>
-                    <div class="verification-icon">🔐</div>
-                    <div class="verification-description">Crea tu PIN de seguridad para comenzar</div>
-                    <div class="verification-description">Vence en <strong>1 hora</strong></div>
+                    <img class="verification-icon" src="https://www.emojiall.com/images/240/emojitwo/1f510.png"/>
                     <a href='"""+CURRENT_URL+"""/verify?q={verification_code}' class="cta-button">Crear mi PIN ahora</a>
+                    <div class="verification-description-2">El link vence en <strong>1 hora</strong></div>
                 </div>
                 
+                
+                
+                
                 <!-- Security Note -->  
                 <div class="security-note">
                     <p>🔒 Tu PIN será tu clave personal para acceder de forma segura a {app_name}</p>
                 </div>
-                
                 <!-- Website Section -->
                 <div class="website-section">
                     <p style="color: #6b7280; margin-bottom: 12px;">Accede desde:</p>
                     <a href="https://expressklein.store" class="website-url">expressklein.store</a>
                 </div>
+
+            <!-- Benefits Section -->
+                <div class="benefits-section">
+                    <h3 class="benefits-title">¿Qué puedes hacer con {app_name}?</h3>
+                    <ul class="benefits-list">
+                        <li>Realizar pedidos de forma rápida y sencilla</li>
+                        <li>Acceder a promociones exclusivas</li>
+                        <li>Disfrutar de una experiencia personalizada</li>
+                        <li>Usar nuestra inteligencia artificial</li>
+                    </ul>
+                </div>
             </div>
             
             <!-- Footer -->

+ 1 - 1
public/register/app.js

@@ -104,7 +104,7 @@ document.addEventListener('DOMContentLoaded', async function () {
     const nextIdResponse = await fetch('/api/users/next');
     if (nextIdResponse.ok) {
         const nextIdData = await nextIdResponse.json();
-        document.getElementById('successMessage').innerHTML = `Revisa tu correo electronico para establecer tu PIN<br/><br/>serias ser el <strong>${nextIdData.next_id} usuario 🫢</strong>`;
+        document.getElementById('successMessage').innerHTML = `Revisa tu correo electronico para establecer tu PIN`;
     }
     createGlobalLoader();
     hideGlobalLoader();

+ 86 - 12
public/verify.html

@@ -109,6 +109,49 @@
         Crear PIN
       </button>
     </form>
+
+    <!-- Pantalla de Éxito -->
+    <div id="successScreen" class="hidden bg-white rounded-xl shadow-sm border border-gray-200 p-8 space-y-6">
+      <div class="text-center">
+        <!-- Ícono de éxito -->
+        <div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
+          <svg class="w-8 h-8 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
+          </svg>
+        </div>
+        
+        <h2 class="text-[24px] font-bold text-[#101419] mb-2">¡Registro Exitoso!</h2>
+        <p class="text-sm text-[#58728d] mb-6">
+          Tu cuenta ha sido creada correctamente en Biergarten Klein
+        </p>
+      </div>
+
+      <div class="bg-gray-50 rounded-lg p-4 space-y-3">
+        <div class="text-center">
+          <h3 class="text-sm font-medium text-[#101419] mb-1">Tu número de usuario es:</h3>
+          <div class="text-2xl font-bold text-[#101419] tracking-wide" id="userId">
+            #0000
+          </div>
+          <p class="text-xs text-[#58728d] mt-2">
+            Es un gran placer tenerte con nosotros.
+          </p>
+        </div>
+      </div>
+
+      <div class="space-y-3">
+        <a 
+          href="/" 
+          id="loginLink"
+          class="block w-full bg-[#101419] hover:bg-[#37404a] text-white py-3 rounded-lg font-medium transition-colors duration-200 focus:ring-2 focus:ring-offset-2 focus:ring-[#101419] text-center"
+        >
+          Iniciar Sesión
+        </a>
+        
+        <p class="text-xs text-[#58728d] text-center">
+          Ya puedes usar tu número de usuario y PIN para acceder a tu cuenta
+        </p>
+      </div>
+    </div>
   </div>
 
   <script>
@@ -118,6 +161,9 @@
     const submitBtn = document.getElementById('submitBtn');
     const errorMessage = document.getElementById('errorMessage');
     const successMessage = document.getElementById('successMessage');
+    const successScreen = document.getElementById('successScreen');
+    const userIdElement = document.getElementById('userId');
+    const loginLink = document.getElementById('loginLink');
 
     // Auto-focus en el primer input al cargar
     pinInput.focus();
@@ -169,11 +215,16 @@
         pinInput.focus();
         return;
       }
+      
+      // Deshabilitar el botón mientras se procesa
+      submitBtn.disabled = true;
+      submitBtn.textContent = 'Creando PIN...';
+      
       //get q url query
       const urlParams = new URLSearchParams(window.location.search);
       const q = urlParams.get('q');
-      // PIN válido - simular guardado
-      showSuccess();
+      
+      // PIN válido - enviar al servidor
       fetch(`/api/users/create-user?q=${q}`, {
         method: 'POST',
         headers: {
@@ -182,19 +233,27 @@
         body: JSON.stringify({
           pin: pin
         })
-      }).catch(error => {
-        console.error('Error al crear el PIN:', error);
-        showError('Ocurrió un error al crear el PIN. Inténtalo de nuevo más tarde.');
-      }).then(response => {
-        if (response.status === 201){
-          alert("Bienvenido a Biergarten Klein, tu PIN ha sido creado exitosamente.");
-          window.location.href = '/';
-        }else{
-          response.json().then(data => {
-            showError(data.message || 'Ocurrió un error al crear el PIN. Inténtalo de nuevo más tarde.');
+      })
+      .then(response => {
+        if (response.status === 201) {
+          return response.json();
+        } else {
+          return response.json().then(data => {
+            throw new Error(data.message || 'Ocurrió un error al crear el PIN. Inténtalo de nuevo más tarde.');
           });
         }
       })
+      .then(data => {
+        // Mostrar pantalla de éxito con el ID del usuario
+        showSuccessScreen(data.data.user_id || data.data.id || 'N/A');
+      })
+      .catch(error => {
+        console.error('Error al crear el PIN:', error);
+        showError(error.message || 'Ocurrió un error al crear el PIN. Inténtalo de nuevo más tarde.');
+        // Rehabilitar el botón en caso de error
+        submitBtn.disabled = false;
+        submitBtn.textContent = 'Crear PIN';
+      });
     });
 
     function showError(message) {
@@ -212,6 +271,21 @@
       confirmPinInput.classList.add('border-green-300');
     }
 
+    function showSuccessScreen(userId) {
+      // Ocultar el formulario
+      pinForm.classList.add('hidden');
+      
+      // Mostrar la pantalla de éxito
+      successScreen.classList.remove('hidden');
+      
+      // Actualizar el ID del usuario
+      userIdElement.textContent = `#${userId}`;
+      
+      // Configurar el enlace de inicio de sesión con la URL base
+      const currentUrl = window.location.origin; // Esto obtiene la URL base actual
+      loginLink.href = currentUrl;
+    }
+
     function resetInputStyles() {
       pinInput.classList.remove('border-red-300', 'border-green-300');
       confirmPinInput.classList.remove('border-red-300', 'border-green-300');