- Changed Supabase URL and anon key for the connection. - Added a cache buster file for page caching management. - Integrated ChatMessages component into AcompanhamentoPaciente and MensagensMedico pages for improved messaging interface. - Created new MensagensPaciente page for patient messaging. - Updated PainelMedico to include messaging functionality with patients. - Enhanced message service to support conversation retrieval and message sending. - Added a test HTML file for Supabase connection verification and message table interaction.
157 lines
5.5 KiB
HTML
157 lines
5.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="pt-BR">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Teste Conexão Supabase</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
.container {
|
|
background: white;
|
|
padding: 30px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
}
|
|
h1 { color: #333; }
|
|
button {
|
|
background: #3b82f6;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
margin: 5px;
|
|
}
|
|
button:hover { background: #2563eb; }
|
|
.result {
|
|
margin-top: 20px;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
white-space: pre-wrap;
|
|
font-family: monospace;
|
|
}
|
|
.success { background: #d1fae5; color: #065f46; }
|
|
.error { background: #fee2e2; color: #991b1b; }
|
|
input {
|
|
width: 100%;
|
|
padding: 10px;
|
|
margin: 10px 0;
|
|
border: 1px solid #ddd;
|
|
border-radius: 5px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🔍 Teste de Conexão Supabase</h1>
|
|
|
|
<h3>1. Verifique suas credenciais:</h3>
|
|
<p>Vá para: <a href="https://supabase.com/dashboard/project/beffilzgxsdvvrlitqtw/settings/api" target="_blank">Configurações API do Supabase</a></p>
|
|
|
|
<label>URL do Projeto:</label>
|
|
<input type="text" id="supabaseUrl" value="https://beffilzgxsdvvrlitqtw.supabase.co">
|
|
|
|
<label>Chave Anon (pública):</label>
|
|
<input type="text" id="supabaseKey" value="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJlZmZpbHpneHNkdnZybGl0cXR3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjM2ODIyMTUsImV4cCI6MjA3OTI1ODIxNX0.jzYLs5m5OerXp6xTTXmuHki2j41jcp4COQRYwWAZLpQ">
|
|
|
|
<h3>2. Testes:</h3>
|
|
<button onclick="testConnection()">Testar Conexão</button>
|
|
<button onclick="testMessagesTable()">Verificar Tabela Messages</button>
|
|
<button onclick="testInsertMessage()">Testar INSERT</button>
|
|
|
|
<div id="result"></div>
|
|
</div>
|
|
|
|
<script>
|
|
let supabase;
|
|
|
|
function initSupabase() {
|
|
const url = document.getElementById('supabaseUrl').value;
|
|
const key = document.getElementById('supabaseKey').value;
|
|
supabase = window.supabase.createClient(url, key);
|
|
}
|
|
|
|
function showResult(message, isError = false) {
|
|
const resultDiv = document.getElementById('result');
|
|
resultDiv.className = 'result ' + (isError ? 'error' : 'success');
|
|
resultDiv.textContent = message;
|
|
}
|
|
|
|
async function testConnection() {
|
|
initSupabase();
|
|
showResult('Testando conexão...');
|
|
|
|
try {
|
|
// Tenta fazer uma query simples
|
|
const { data, error } = await supabase
|
|
.from('messages')
|
|
.select('count', { count: 'exact', head: true });
|
|
|
|
if (error) {
|
|
showResult(`❌ ERRO na conexão:\n\n${JSON.stringify(error, null, 2)}`, true);
|
|
} else {
|
|
showResult(`✅ CONEXÃO OK!\n\nTabela 'messages' acessível.`, false);
|
|
}
|
|
} catch (err) {
|
|
showResult(`❌ ERRO:\n\n${err.message}`, true);
|
|
}
|
|
}
|
|
|
|
async function testMessagesTable() {
|
|
initSupabase();
|
|
showResult('Verificando tabela messages...');
|
|
|
|
try {
|
|
const { data, error, count } = await supabase
|
|
.from('messages')
|
|
.select('*', { count: 'exact' })
|
|
.limit(5);
|
|
|
|
if (error) {
|
|
showResult(`❌ ERRO:\n\n${JSON.stringify(error, null, 2)}`, true);
|
|
} else {
|
|
showResult(`✅ Tabela OK!\n\nTotal de mensagens: ${count}\n\nPrimeiras mensagens:\n${JSON.stringify(data, null, 2)}`, false);
|
|
}
|
|
} catch (err) {
|
|
showResult(`❌ ERRO:\n\n${err.message}`, true);
|
|
}
|
|
}
|
|
|
|
async function testInsertMessage() {
|
|
initSupabase();
|
|
showResult('Testando INSERT...');
|
|
|
|
try {
|
|
const testMessage = {
|
|
sender_id: 'test-sender-123',
|
|
receiver_id: 'test-receiver-456',
|
|
content: 'Mensagem de teste: ' + new Date().toISOString(),
|
|
read: false
|
|
};
|
|
|
|
const { data, error } = await supabase
|
|
.from('messages')
|
|
.insert(testMessage)
|
|
.select()
|
|
.single();
|
|
|
|
if (error) {
|
|
showResult(`❌ ERRO ao inserir:\n\n${JSON.stringify(error, null, 2)}`, true);
|
|
} else {
|
|
showResult(`✅ INSERT OK!\n\nMensagem criada:\n${JSON.stringify(data, null, 2)}`, false);
|
|
}
|
|
} catch (err) {
|
|
showResult(`❌ ERRO:\n\n${err.message}`, true);
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|