78 lines
2.4 KiB
JavaScript
78 lines
2.4 KiB
JavaScript
// Script de teste para cadastrar paciente via API Supabase
|
|
import axios from "axios";
|
|
|
|
const SUPABASE_URL = "https://yuanqfswhberkoevtmfr.supabase.co";
|
|
const SUPABASE_ANON_KEY =
|
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inl1YW5xZnN3aGJlcmtvZXZ0bWZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ5NTQzNjksImV4cCI6MjA3MDUzMDM2OX0.g8Fm4XAvtX46zifBZnYVH4tVuQkqUH6Ia9CXQj4DztQ";
|
|
|
|
async function testCadastroPaciente() {
|
|
try {
|
|
console.log("\n🧪 [TESTE] Iniciando cadastro de paciente SQUAD 18...\n");
|
|
|
|
const pacienteData = {
|
|
email: "teste.squad18@clinica.com",
|
|
password: "123456",
|
|
data: {
|
|
full_name: "Paciente Teste SQUAD 18",
|
|
phone: "11999998888",
|
|
cpf: "12345678900",
|
|
data_nascimento: "1990-01-01",
|
|
endereco: {
|
|
cep: "01310100",
|
|
rua: "Avenida Paulista",
|
|
numero: "1000",
|
|
bairro: "Bela Vista",
|
|
cidade: "São Paulo",
|
|
estado: "SP",
|
|
},
|
|
role: "paciente",
|
|
},
|
|
};
|
|
|
|
console.log("📤 Enviando dados para API Supabase:");
|
|
console.log(" Endpoint: /auth/v1/signup");
|
|
console.log(" Email:", pacienteData.email);
|
|
console.log(" Nome:", pacienteData.data.full_name);
|
|
console.log(" Role:", pacienteData.data.role);
|
|
console.log("");
|
|
|
|
const response = await axios.post(
|
|
`${SUPABASE_URL}/auth/v1/signup`,
|
|
pacienteData,
|
|
{
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
apikey: SUPABASE_ANON_KEY,
|
|
Authorization: `Bearer ${SUPABASE_ANON_KEY}`,
|
|
},
|
|
}
|
|
);
|
|
|
|
console.log("✅ [SUCESSO] Paciente cadastrado na API Supabase!");
|
|
console.log("");
|
|
console.log("📋 Resposta da API:");
|
|
console.log(JSON.stringify(response.data, null, 2));
|
|
console.log("");
|
|
console.log(
|
|
"🎯 ID do usuário:",
|
|
response.data.user?.id || response.data.id
|
|
);
|
|
console.log("📧 Email:", response.data.user?.email || response.data.email);
|
|
console.log("");
|
|
console.log("✨ TESTE CONCLUÍDO COM SUCESSO! ✨");
|
|
console.log("");
|
|
} catch (error) {
|
|
console.error("❌ [ERRO] Falha no cadastro:");
|
|
console.error("");
|
|
if (error.response) {
|
|
console.error("Status:", error.response.status);
|
|
console.error("Dados:", JSON.stringify(error.response.data, null, 2));
|
|
} else {
|
|
console.error("Mensagem:", error.message);
|
|
}
|
|
console.error("");
|
|
}
|
|
}
|
|
|
|
testCadastroPaciente();
|