xlorfx commited on
Commit
9679556
·
verified ·
1 Parent(s): 869a060

Add 1 files

Browse files
Files changed (1) hide show
  1. index.html +115 -166
index.html CHANGED
@@ -200,10 +200,10 @@
200
  .pix-form.active {
201
  display: block;
202
  }
203
- .pagarme-form {
204
  display: none;
205
  }
206
- .pagarme-form.active {
207
  display: block;
208
  }
209
  .card-element {
@@ -785,13 +785,13 @@
785
  <p class="text-sm text-gray-400">Pagamento instantâneo via PIX</p>
786
  </div>
787
  </div>
788
- <div class="payment-method" data-method="pagarme">
789
  <div class="payment-icon gradient-bg">
790
  <i class="fas fa-credit-card text-white"></i>
791
  </div>
792
  <div>
793
  <h4 class="font-medium">Pagar.me</h4>
794
- <p class="text-sm text-gray-400">Pagamento seguro com Pagar.me</p>
795
  </div>
796
  </div>
797
  </div>
@@ -817,28 +817,18 @@
817
  </button>
818
  </div>
819
 
820
- <div id="pagarmeForm" class="pagarme-form">
821
- <div class="mb-4">
822
- <label for="pagarme-card-number" class="block text-gray-300 mb-2">Número do Cartão</label>
823
- <input type="text" id="pagarme-card-number" class="w-full px-4 py-2 bg-gray-800 rounded-lg border border-gray-700 focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="4242 4242 4242 4242">
824
- </div>
825
- <div class="grid grid-cols-2 gap-4 mb-4">
826
- <div>
827
- <label for="pagarme-card-expiry" class="block text-gray-300 mb-2">Validade</label>
828
- <input type="text" id="pagarme-card-expiry" class="w-full px-4 py-2 bg-gray-800 rounded-lg border border-gray-700 focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="MM/AA">
829
- </div>
830
- <div>
831
- <label for="pagarme-card-cvv" class="block text-gray-300 mb-2">CVV</label>
832
- <input type="text" id="pagarme-card-cvv" class="w-full px-4 py-2 bg-gray-800 rounded-lg border border-gray-700 focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="123">
833
  </div>
834
  </div>
835
- <div class="mb-4">
836
- <label for="pagarme-card-name" class="block text-gray-300 mb-2">Nome no Cartão</label>
837
- <input type="text" id="pagarme-card-name" class="w-full px-4 py-2 bg-gray-800 rounded-lg border border-gray-700 focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="Nome como no cartão">
838
- </div>
839
- <button id="submitPagarmePayment" class="w-full gradient-bg text-white py-2 px-4 rounded-lg hover:opacity-90 transition">
840
- Pagar com Pagar.me
841
- </button>
842
  </div>
843
 
844
  <div class="text-center mt-6">
@@ -857,7 +847,7 @@
857
  const API_CONFIG = {
858
  baseUrl: 'https://api.spysmartai.com/v1',
859
  stripePublicKey: 'pk_test_your_stripe_public_key_here',
860
- pagarmeEncryptionKey: 'ek_test_your_pagarme_encryption_key_here',
861
  mistralApiKey: 'sk_your_mistral_api_key_here',
862
  n8nWebhookUrl: 'https://your-n8n-instance.com/webhook/path',
863
  competitorEndpoint: 'https://seu-replit.seu-usuario.repl.co/add-competitor'
@@ -922,12 +912,13 @@
922
  const paymentMethods = document.querySelectorAll('.payment-method');
923
  const creditCardForm = document.getElementById('creditCardForm');
924
  const pixForm = document.getElementById('pixForm');
925
- const pagarmeForm = document.getElementById('pagarmeForm');
 
 
926
  const planCounter = document.getElementById('planCounter');
927
  const analysisCount = document.getElementById('analysisCount');
928
  const analysisLimit = document.getElementById('analysisLimit');
929
  const selectPlanBtns = document.querySelectorAll('.select-plan-btn');
930
- const submitPagarmePayment = document.getElementById('submitPagarmePayment');
931
 
932
  // =============================================
933
  // EVENT LISTENERS
@@ -950,7 +941,8 @@
950
  selectPlanBtns.forEach(btn => {
951
  btn.addEventListener('click', handlePlanSelection);
952
  });
953
- submitPagarmePayment.addEventListener('click', handlePagarmePayment);
 
954
 
955
  // Initialize Stripe
956
  const stripe = Stripe(API_CONFIG.stripePublicKey);
@@ -958,24 +950,6 @@
958
  const cardElement = elements.create('card');
959
  cardElement.mount('#card-element');
960
 
961
- // Initialize Pagar.me Checkout
962
- const pagarmeCheckout = new PagarMeCheckout.Checkout({
963
- encryption_key: API_CONFIG.pagarmeEncryptionKey,
964
- success: function(data) {
965
- console.log('Pagamento via Pagar.me realizado com sucesso:', data);
966
- alert('Pagamento realizado com sucesso! Seu plano Pro foi ativado.');
967
- upgradeUserPlan();
968
- hideUpgradeModal();
969
- },
970
- error: function(err) {
971
- console.error('Erro no pagamento via Pagar.me:', err);
972
- alert('Erro ao processar pagamento: ' + err.message);
973
- },
974
- close: function() {
975
- console.log('Modal Pagar.me fechado');
976
- }
977
- });
978
-
979
  // =============================================
980
  // FUNÇÕES PRINCIPAIS
981
  // =============================================
@@ -1068,15 +1042,15 @@
1068
  // Hide all forms first
1069
  creditCardForm.classList.remove('active');
1070
  pixForm.classList.remove('active');
1071
- pagarmeForm.classList.remove('active');
1072
 
1073
  // Show selected form
1074
  if (methodType === 'credit_card') {
1075
  creditCardForm.classList.add('active');
1076
  } else if (methodType === 'pix') {
1077
  pixForm.classList.add('active');
1078
- } else if (methodType === 'pagarme') {
1079
- pagarmeForm.classList.add('active');
1080
  }
1081
  }
1082
 
@@ -1102,6 +1076,79 @@
1102
  }
1103
  }
1104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1105
  function handleLogin(e) {
1106
  e.preventDefault();
1107
  const email = document.getElementById('loginEmail').value;
@@ -1130,18 +1177,18 @@
1130
  const confirmPassword = document.getElementById('confirmPassword').value;
1131
  const company = document.getElementById('company').value;
1132
  const position = document.getElementById('position').value;
1133
-
1134
  if (password !== confirmPassword) {
1135
  alert('As senhas não coincidem');
1136
  return;
1137
  }
1138
-
1139
  // Verificar se o usuário já existe
1140
  if (usersDB.some(u => u.email === email)) {
1141
  alert('Este e-mail já está cadastrado');
1142
  return;
1143
  }
1144
-
1145
  // Criar novo usuário
1146
  const newUser = {
1147
  id: Date.now().toString(),
@@ -1156,13 +1203,13 @@
1156
  competitorsCount: 0,
1157
  analysisCount: 0
1158
  };
1159
-
1160
  usersDB.push(newUser);
1161
  localStorage.setItem('usersDB', JSON.stringify(usersDB));
1162
-
1163
  currentUser = newUser;
1164
  localStorage.setItem('currentUser', JSON.stringify(currentUser));
1165
-
1166
  hideSignupModal();
1167
  showDashboard();
1168
  alert('Cadastro realizado com sucesso! Bem-vindo ao seu teste gratuito de 7 dias.');
@@ -1176,7 +1223,7 @@
1176
  showUpgradeModal('Você atingiu o limite de 3 concorrentes no plano Starter. Faça upgrade para Pro para adicionar mais concorrentes.');
1177
  return;
1178
  }
1179
-
1180
  const competitorData = {
1181
  id: Date.now().toString(),
1182
  name: document.getElementById('competitorName').value,
@@ -1189,7 +1236,7 @@
1189
  status: 'active',
1190
  lastUpdate: new Date().toISOString().split('T')[0]
1191
  };
1192
-
1193
  // Simulação de chamada à API
1194
  try {
1195
  // Adiciona o concorrente localmente
@@ -1214,7 +1261,7 @@
1214
  },
1215
  body: JSON.stringify(competitorData)
1216
  });
1217
-
1218
  if (response.ok) {
1219
  loadCompetitors();
1220
  hideAddCompetitorForm();
@@ -1229,104 +1276,6 @@
1229
  }
1230
  }
1231
 
1232
- function handlePagarmePayment() {
1233
- const cardNumber = document.getElementById('pagarme-card-number').value;
1234
- const cardExpiry = document.getElementById('pagarme-card-expiry').value;
1235
- const cardCvv = document.getElementById('pagarme-card-cvv').value;
1236
- const cardName = document.getElementById('pagarme-card-name').value;
1237
-
1238
- if (!cardNumber || !cardExpiry || !cardCvv || !cardName) {
1239
- alert('Por favor, preencha todos os campos do cartão');
1240
- return;
1241
- }
1242
-
1243
- // Configuração do pagamento
1244
- const paymentData = {
1245
- amount: 19700, // R$ 197.00 em centavos
1246
- payment_method: 'credit_card',
1247
- card_number: cardNumber.replace(/\s+/g, ''),
1248
- card_expiration_date: cardExpiry.replace('/', ''),
1249
- card_cvv: cardCvv,
1250
- card_holder_name: cardName,
1251
- customer: {
1252
- external_id: currentUser?.id || 'guest_' + Date.now(),
1253
- name: currentUser?.firstName + ' ' + currentUser?.lastName || 'Cliente SpySmartAI',
1254
- email: currentUser?.email || 'guest@spysmartai.com',
1255
- type: 'individual',
1256
- country: 'br',
1257
- documents: [
1258
- {
1259
- type: 'cpf',
1260
- number: '00000000000' // CPF fictício para demonstração
1261
- }
1262
- ],
1263
- phone_numbers: ['+5511999999999']
1264
- },
1265
- billing: {
1266
- name: currentUser?.firstName + ' ' + currentUser?.lastName || 'Cliente SpySmartAI',
1267
- address: {
1268
- country: 'br',
1269
- state: 'sp',
1270
- city: 'São Paulo',
1271
- neighborhood: 'Centro',
1272
- street: 'Av. Paulista',
1273
- street_number: '1000',
1274
- zipcode: '01310000'
1275
- }
1276
- },
1277
- items: [
1278
- {
1279
- id: 'pro_plan',
1280
- title: 'Plano Pro SpySmartAI',
1281
- unit_price: 19700,
1282
- quantity: 1,
1283
- tangible: false
1284
- }
1285
- ]
1286
- };
1287
-
1288
- // Abrir modal de pagamento Pagar.me
1289
- pagarmeCheckout.open({
1290
- amount: paymentData.amount,
1291
- buttonText: 'Pagar R$ 197,00',
1292
- buttonClass: 'pagarme-button',
1293
- customerData: 'false',
1294
- paymentMethods: 'credit_card',
1295
- createToken: 'true',
1296
- uiColor: '#6e8efb',
1297
- maxInstallments: 12,
1298
- defaultInstallment: 1,
1299
- interestRate: 0,
1300
- freeInstallments: 1,
1301
- postback_url: API_CONFIG.baseUrl + '/pagarme/webhook',
1302
- headers: {
1303
- 'Authorization': 'Bearer ' + API_CONFIG.pagarmeEncryptionKey
1304
- }
1305
- });
1306
-
1307
- // Em um ambiente real, você enviaria os dados para seu backend
1308
- // que então processaria o pagamento com a API da Pagar.me
1309
- console.log('Dados do pagamento via Pagar.me:', paymentData);
1310
- }
1311
-
1312
- function upgradeUserPlan() {
1313
- if (!currentUser) return;
1314
-
1315
- currentUser.plan = 'pro';
1316
- currentUser.trialEnd = null;
1317
- localStorage.setItem('currentUser', JSON.stringify(currentUser));
1318
-
1319
- // Atualiza o usuário no "banco de dados"
1320
- const userIndex = usersDB.findIndex(u => u.id === currentUser.id);
1321
- if (userIndex !== -1) {
1322
- usersDB[userIndex] = currentUser;
1323
- localStorage.setItem('usersDB', JSON.stringify(usersDB));
1324
- }
1325
-
1326
- updatePlanCounter();
1327
- alert('Seu plano foi atualizado para Pro com sucesso!');
1328
- }
1329
-
1330
  function loadCompetitors() {
1331
  competitorsList.innerHTML = '';
1332
 
@@ -1340,7 +1289,7 @@
1340
  `;
1341
  return;
1342
  }
1343
-
1344
  competitors.forEach(competitor => {
1345
  const statusClass = competitor.status === 'active' ? 'bg-green-500' : 'bg-yellow-500';
1346
  const statusText = competitor.status === 'active' ? 'Ativo' : 'Em Análise';
@@ -1370,7 +1319,7 @@
1370
  </tr>
1371
  `;
1372
  });
1373
-
1374
  // Adiciona event listeners aos botões
1375
  document.querySelectorAll('.view-report-btn').forEach(btn => {
1376
  btn.addEventListener('click', (e) => {
@@ -1378,7 +1327,7 @@
1378
  viewCompetitorReport(competitorId);
1379
  });
1380
  });
1381
-
1382
  document.querySelectorAll('.delete-competitor-btn').forEach(btn => {
1383
  btn.addEventListener('click', (e) => {
1384
  const competitorId = e.currentTarget.getAttribute('data-id');
@@ -1395,7 +1344,7 @@
1395
  if (currentUser?.plan === 'starter' || currentUser?.plan === 'starter_trial') {
1396
  const remainingAnalyses = 20 - (currentUser.analysisCount || 0);
1397
  if (remainingAnalyses <= 0) {
1398
- showUpgradeModal('Você atingiu o limite de 20 análises mensais no plano Starter. Faça upgrade para Pro para análise ilimitadas.');
1399
  return;
1400
  }
1401
 
@@ -1407,7 +1356,7 @@
1407
 
1408
  // Atualiza o relatório na UI
1409
  document.getElementById('currentCompetitor').textContent = competitor.name;
1410
-
1411
  // Aqui você buscaria os dados reais da API
1412
  // Por enquanto estamos usando dados mockados
1413
  const detectedStrategies = [
@@ -1415,19 +1364,19 @@
1415
  'Uso intensivo de anúncios no Instagram',
1416
  'Preços dinâmicos baseados em concorrência'
1417
  ];
1418
-
1419
  const strengthsList = [
1420
  'Fotos de produtos em alta qualidade',
1421
  'Atendimento rápido via WhatsApp',
1422
  'Frete grátis acima de R$ 150'
1423
  ];
1424
-
1425
  const suggestionsList = [
1426
  'Criar promoções nas mesmas datas',
1427
  'Melhorar descrições de produtos',
1428
  'Oferecer frete grátis em compras menores'
1429
  ];
1430
-
1431
  // Preenche as listas
1432
  const detectedStrategiesEl = document.getElementById('detectedStrategies');
1433
  const strengthsListEl = document.getElementById('strengthsList');
@@ -1436,7 +1385,7 @@
1436
  detectedStrategiesEl.innerHTML = detectedStrategies.map(item => `<li>${item}</li>`).join('');
1437
  strengthsListEl.innerHTML = strengthsList.map(item => `<li>${item}</li>`).join('');
1438
  suggestionsListEl.innerHTML = suggestionsList.map(item => `<li>${item}</li>`).join('');
1439
-
1440
  // Rola até a seção de relatórios
1441
  document.querySelector('#dashboardSection').scrollIntoView({
1442
  behavior: 'smooth'
@@ -1463,7 +1412,7 @@
1463
  "Dados em Tempo Real",
1464
  "Relatórios Automatizados"
1465
  ];
1466
-
1467
  let wordIndex = 0;
1468
  let charIndex = 0;
1469
  let isDeleting = false;
 
200
  .pix-form.active {
201
  display: block;
202
  }
203
+ .pagar-me-form {
204
  display: none;
205
  }
206
+ .pagar-me-form.active {
207
  display: block;
208
  }
209
  .card-element {
 
785
  <p class="text-sm text-gray-400">Pagamento instantâneo via PIX</p>
786
  </div>
787
  </div>
788
+ <div class="payment-method" data-method="pagar_me">
789
  <div class="payment-icon gradient-bg">
790
  <i class="fas fa-credit-card text-white"></i>
791
  </div>
792
  <div>
793
  <h4 class="font-medium">Pagar.me</h4>
794
+ <p class="text-sm text-gray-400">Pagamento via Pagar.me (cartão ou boleto)</p>
795
  </div>
796
  </div>
797
  </div>
 
817
  </button>
818
  </div>
819
 
820
+ <div id="pagarMeForm" class="pagar-me-form">
821
+ <div class="text-center mb-4">
822
+ <p class="text-gray-300 mb-2">Você será redirecionado para o Pagar.me para finalizar o pagamento</p>
823
+ <div class="flex justify-center space-x-4">
824
+ <button id="pagarMeCreditCard" class="gradient-bg text-white py-2 px-4 rounded-lg hover:opacity-90 transition">
825
+ Cartão de Crédito
826
+ </button>
827
+ <button id="pagarMeBoleto" class="bg-gray-700 text-white py-2 px-4 rounded-lg hover:bg-gray-600 transition">
828
+ Boleto Bancário
829
+ </button>
 
 
 
830
  </div>
831
  </div>
 
 
 
 
 
 
 
832
  </div>
833
 
834
  <div class="text-center mt-6">
 
847
  const API_CONFIG = {
848
  baseUrl: 'https://api.spysmartai.com/v1',
849
  stripePublicKey: 'pk_test_your_stripe_public_key_here',
850
+ pagarmePublicKey: 'pk_test_your_pagarme_public_key_here',
851
  mistralApiKey: 'sk_your_mistral_api_key_here',
852
  n8nWebhookUrl: 'https://your-n8n-instance.com/webhook/path',
853
  competitorEndpoint: 'https://seu-replit.seu-usuario.repl.co/add-competitor'
 
912
  const paymentMethods = document.querySelectorAll('.payment-method');
913
  const creditCardForm = document.getElementById('creditCardForm');
914
  const pixForm = document.getElementById('pixForm');
915
+ const pagarMeForm = document.getElementById('pagarMeForm');
916
+ const pagarMeCreditCard = document.getElementById('pagarMeCreditCard');
917
+ const pagarMeBoleto = document.getElementById('pagarMeBoleto');
918
  const planCounter = document.getElementById('planCounter');
919
  const analysisCount = document.getElementById('analysisCount');
920
  const analysisLimit = document.getElementById('analysisLimit');
921
  const selectPlanBtns = document.querySelectorAll('.select-plan-btn');
 
922
 
923
  // =============================================
924
  // EVENT LISTENERS
 
941
  selectPlanBtns.forEach(btn => {
942
  btn.addEventListener('click', handlePlanSelection);
943
  });
944
+ pagarMeCreditCard?.addEventListener('click', () => processPagarMePayment('credit_card'));
945
+ pagarMeBoleto?.addEventListener('click', () => processPagarMePayment('boleto'));
946
 
947
  // Initialize Stripe
948
  const stripe = Stripe(API_CONFIG.stripePublicKey);
 
950
  const cardElement = elements.create('card');
951
  cardElement.mount('#card-element');
952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
953
  // =============================================
954
  // FUNÇÕES PRINCIPAIS
955
  // =============================================
 
1042
  // Hide all forms first
1043
  creditCardForm.classList.remove('active');
1044
  pixForm.classList.remove('active');
1045
+ pagarMeForm.classList.remove('active');
1046
 
1047
  // Show selected form
1048
  if (methodType === 'credit_card') {
1049
  creditCardForm.classList.add('active');
1050
  } else if (methodType === 'pix') {
1051
  pixForm.classList.add('active');
1052
+ } else if (methodType === 'pagar_me') {
1053
+ pagarMeForm.classList.add('active');
1054
  }
1055
  }
1056
 
 
1076
  }
1077
  }
1078
 
1079
+ function processPagarMePayment(paymentMethod) {
1080
+ // Configuração do checkout Pagar.me
1081
+ const checkout = new PagarMeCheckout.Checkout({
1082
+ encryption_key: API_CONFIG.pagarmePublicKey,
1083
+ success: function(data) {
1084
+ alert('Pagamento realizado com sucesso! ID da transação: ' + data.id);
1085
+ hideUpgradeModal();
1086
+ // Atualizar o plano do usuário para Pro
1087
+ if (currentUser) {
1088
+ currentUser.plan = 'pro';
1089
+ localStorage.setItem('currentUser', JSON.stringify(currentUser));
1090
+ alert('Seu plano foi atualizado para Pro com sucesso!');
1091
+ updatePlanCounter();
1092
+ }
1093
+ },
1094
+ error: function(err) {
1095
+ console.error('Erro no pagamento:', err);
1096
+ alert('Ocorreu um erro ao processar seu pagamento. Por favor, tente novamente.');
1097
+ },
1098
+ close: function() {
1099
+ console.log('Modal de pagamento fechado');
1100
+ }
1101
+ });
1102
+
1103
+ // Configuração da transação
1104
+ const paymentData = {
1105
+ amount: 19700, // R$ 197,00 em centavos
1106
+ buttonText: 'Pagar R$ 197,00',
1107
+ customerData: 'true',
1108
+ createToken: 'false',
1109
+ paymentMethod: paymentMethod,
1110
+ postbackUrl: API_CONFIG.n8nWebhookUrl,
1111
+ items: [
1112
+ {
1113
+ id: 'pro_plan',
1114
+ title: 'Plano Pro SpySmartAI',
1115
+ unit_price: 19700,
1116
+ quantity: 1,
1117
+ tangible: false
1118
+ }
1119
+ ],
1120
+ customer: {
1121
+ name: currentUser?.firstName + ' ' + currentUser?.lastName,
1122
+ email: currentUser?.email,
1123
+ external_id: currentUser?.id || 'guest_' + Date.now(),
1124
+ type: 'individual',
1125
+ country: 'br',
1126
+ documents: [
1127
+ {
1128
+ type: 'cpf',
1129
+ number: '00000000000' // Substituir por CPF real em produção
1130
+ }
1131
+ ],
1132
+ phone_numbers: ['+5511999999999'] // Substituir por telefone real em produção
1133
+ },
1134
+ billing: {
1135
+ name: currentUser?.firstName + ' ' + currentUser?.lastName,
1136
+ address: {
1137
+ country: 'br',
1138
+ state: 'sp',
1139
+ city: 'São Paulo',
1140
+ neighborhood: 'Centro',
1141
+ street: 'Av. Paulista',
1142
+ street_number: '1000',
1143
+ zipcode: '01310000'
1144
+ }
1145
+ }
1146
+ };
1147
+
1148
+ // Abrir modal de pagamento do Pagar.me
1149
+ checkout.open(paymentData);
1150
+ }
1151
+
1152
  function handleLogin(e) {
1153
  e.preventDefault();
1154
  const email = document.getElementById('loginEmail').value;
 
1177
  const confirmPassword = document.getElementById('confirmPassword').value;
1178
  const company = document.getElementById('company').value;
1179
  const position = document.getElementById('position').value;
1180
+
1181
  if (password !== confirmPassword) {
1182
  alert('As senhas não coincidem');
1183
  return;
1184
  }
1185
+
1186
  // Verificar se o usuário já existe
1187
  if (usersDB.some(u => u.email === email)) {
1188
  alert('Este e-mail já está cadastrado');
1189
  return;
1190
  }
1191
+
1192
  // Criar novo usuário
1193
  const newUser = {
1194
  id: Date.now().toString(),
 
1203
  competitorsCount: 0,
1204
  analysisCount: 0
1205
  };
1206
+
1207
  usersDB.push(newUser);
1208
  localStorage.setItem('usersDB', JSON.stringify(usersDB));
1209
+
1210
  currentUser = newUser;
1211
  localStorage.setItem('currentUser', JSON.stringify(currentUser));
1212
+
1213
  hideSignupModal();
1214
  showDashboard();
1215
  alert('Cadastro realizado com sucesso! Bem-vindo ao seu teste gratuito de 7 dias.');
 
1223
  showUpgradeModal('Você atingiu o limite de 3 concorrentes no plano Starter. Faça upgrade para Pro para adicionar mais concorrentes.');
1224
  return;
1225
  }
1226
+
1227
  const competitorData = {
1228
  id: Date.now().toString(),
1229
  name: document.getElementById('competitorName').value,
 
1236
  status: 'active',
1237
  lastUpdate: new Date().toISOString().split('T')[0]
1238
  };
1239
+
1240
  // Simulação de chamada à API
1241
  try {
1242
  // Adiciona o concorrente localmente
 
1261
  },
1262
  body: JSON.stringify(competitorData)
1263
  });
1264
+
1265
  if (response.ok) {
1266
  loadCompetitors();
1267
  hideAddCompetitorForm();
 
1276
  }
1277
  }
1278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1279
  function loadCompetitors() {
1280
  competitorsList.innerHTML = '';
1281
 
 
1289
  `;
1290
  return;
1291
  }
1292
+
1293
  competitors.forEach(competitor => {
1294
  const statusClass = competitor.status === 'active' ? 'bg-green-500' : 'bg-yellow-500';
1295
  const statusText = competitor.status === 'active' ? 'Ativo' : 'Em Análise';
 
1319
  </tr>
1320
  `;
1321
  });
1322
+
1323
  // Adiciona event listeners aos botões
1324
  document.querySelectorAll('.view-report-btn').forEach(btn => {
1325
  btn.addEventListener('click', (e) => {
 
1327
  viewCompetitorReport(competitorId);
1328
  });
1329
  });
1330
+
1331
  document.querySelectorAll('.delete-competitor-btn').forEach(btn => {
1332
  btn.addEventListener('click', (e) => {
1333
  const competitorId = e.currentTarget.getAttribute('data-id');
 
1344
  if (currentUser?.plan === 'starter' || currentUser?.plan === 'starter_trial') {
1345
  const remainingAnalyses = 20 - (currentUser.analysisCount || 0);
1346
  if (remainingAnalyses <= 0) {
1347
+ showUpgradeModal('Você atingiu o limite de 20 análises mensais no plano Starter. Faça upgrade para Pro para análises ilimitadas.');
1348
  return;
1349
  }
1350
 
 
1356
 
1357
  // Atualiza o relatório na UI
1358
  document.getElementById('currentCompetitor').textContent = competitor.name;
1359
+
1360
  // Aqui você buscaria os dados reais da API
1361
  // Por enquanto estamos usando dados mockados
1362
  const detectedStrategies = [
 
1364
  'Uso intensivo de anúncios no Instagram',
1365
  'Preços dinâmicos baseados em concorrência'
1366
  ];
1367
+
1368
  const strengthsList = [
1369
  'Fotos de produtos em alta qualidade',
1370
  'Atendimento rápido via WhatsApp',
1371
  'Frete grátis acima de R$ 150'
1372
  ];
1373
+
1374
  const suggestionsList = [
1375
  'Criar promoções nas mesmas datas',
1376
  'Melhorar descrições de produtos',
1377
  'Oferecer frete grátis em compras menores'
1378
  ];
1379
+
1380
  // Preenche as listas
1381
  const detectedStrategiesEl = document.getElementById('detectedStrategies');
1382
  const strengthsListEl = document.getElementById('strengthsList');
 
1385
  detectedStrategiesEl.innerHTML = detectedStrategies.map(item => `<li>${item}</li>`).join('');
1386
  strengthsListEl.innerHTML = strengthsList.map(item => `<li>${item}</li>`).join('');
1387
  suggestionsListEl.innerHTML = suggestionsList.map(item => `<li>${item}</li>`).join('');
1388
+
1389
  // Rola até a seção de relatórios
1390
  document.querySelector('#dashboardSection').scrollIntoView({
1391
  behavior: 'smooth'
 
1412
  "Dados em Tempo Real",
1413
  "Relatórios Automatizados"
1414
  ];
1415
+
1416
  let wordIndex = 0;
1417
  let charIndex = 0;
1418
  let isDeleting = false;