ModalWhatsappConexao.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <Teleport to="body">
  3. <div class="fixed inset-0 z-[9999] flex items-center justify-center p-4" @click="$emit('close')">
  4. <div class="absolute inset-0 bg-black/40 dark:bg-black/60" />
  5. <div
  6. class="relative w-full max-w-sm overflow-hidden rounded-2xl border border-gray-200 bg-background text-foreground shadow-xl dark:border-gray-700"
  7. @click.stop
  8. >
  9. <div class="flex items-center justify-between gap-3 border-b border-gray-200 px-5 py-4 dark:border-gray-700">
  10. <h3 class="text-base font-semibold text-gray-900 dark:text-gray-100">Conectar WhatsApp</h3>
  11. <button
  12. type="button"
  13. class="rounded-lg border border-transparent p-1.5 text-gray-500 transition-colors hover:border-gray-200 hover:bg-gray-100 dark:text-gray-400 dark:hover:border-gray-700 dark:hover:bg-white/5"
  14. @click="$emit('close')"
  15. >
  16. <svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  17. <path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
  18. </svg>
  19. </button>
  20. </div>
  21. <div class="flex flex-col items-center gap-4 p-6">
  22. <template v-if="status === 'qr_pendente' && qrDataUrl">
  23. <img :src="qrDataUrl" alt="QR code de conexão do WhatsApp" class="h-56 w-56 rounded-lg border border-gray-200 dark:border-gray-700" />
  24. <p class="text-center text-sm text-gray-600 dark:text-gray-300">
  25. Abra o WhatsApp no celular que vai atender → Configurações → Aparelhos conectados → Conectar aparelho e escaneie o código acima.
  26. </p>
  27. </template>
  28. <template v-else-if="status === 'conectando'">
  29. <p class="text-sm text-gray-500 dark:text-gray-400">Gerando código de conexão...</p>
  30. </template>
  31. <template v-else-if="status === 'conectado'">
  32. <p class="text-sm font-medium text-emerald-600 dark:text-emerald-400">Conectado com sucesso!</p>
  33. <p class="text-sm text-gray-500 dark:text-gray-400">Número: {{ telefone }}</p>
  34. </template>
  35. <template v-else>
  36. <p class="text-sm text-gray-500 dark:text-gray-400">Sem conexão ativa.</p>
  37. </template>
  38. <p v-if="erro" class="w-full rounded-lg bg-red-50 px-4 py-3 text-xs text-red-800 dark:bg-red-900/30 dark:text-red-300">
  39. {{ erro }}
  40. </p>
  41. </div>
  42. </div>
  43. </div>
  44. </Teleport>
  45. </template>
  46. <script setup>
  47. defineProps({
  48. status: { type: String, default: "desconectado" },
  49. qrDataUrl: { type: String, default: null },
  50. telefone: { type: String, default: null },
  51. erro: { type: String, default: "" }
  52. });
  53. defineEmits(["close"]);
  54. </script>