-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (52 loc) · 2.67 KB
/
script.js
File metadata and controls
58 lines (52 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const url = 'https://cors-anywhere.herokuapp.com/https://www.receitaws.com.br/v1/cnpj/00275369000107';
function loadCnpjData() {
fetch(url)
.then(response => response.json())
.then(data => {
if (data.status === 'OK') {
displayCnpjData(data);
} else {
document.getElementById('status').textContent = 'Erro ao carregar dados.';
document.getElementById('status').classList.add('error');
}
})
.catch(error => {
document.getElementById('status').textContent = 'Erro de conexão.';
document.getElementById('status').classList.add('error');
console.error('Erro:', error);
});
}
function displayCnpjData(data) {
const container = document.getElementById('infoContainer');
container.innerHTML = `
<div class="section-title">Informações da Empresa</div>
<div><strong>Nome:</strong> ${data.nome}</div>
<div><strong>Nome Fantasia:</strong> ${data.fantasia}</div>
<div><strong>CNPJ:</strong> ${data.cnpj}</div>
<div><strong>Tipo:</strong> ${data.tipo}</div>
<div><strong>Porte:</strong> ${data.porte}</div>
<div><strong>Natureza Jurídica:</strong> ${data.natureza_juridica}</div>
<div><strong>Atividade Principal:</strong> ${data.atividade_principal[0].text}</div>
<div><strong>Atividade Secundária:</strong> ${data.atividades_secundarias[0].text}</div>
<div><strong>Capital Social:</strong> R$ ${data.capital_social}</div>
<div><strong>Abertura:</strong> ${data.abertura}</div>
<div><strong>Situação:</strong> ${data.situacao}</div>
<div><strong>Data da Situação:</strong> ${data.data_situacao}</div>
<div><strong>Motivo da Situação:</strong> ${data.motivo_situacao}</div>
<div><strong>Logradouro:</strong> ${data.logradouro}, ${data.numero}</div>
<div><strong>Bairro:</strong> ${data.bairro}</div>
<div><strong>Município:</strong> ${data.municipio}</div>
<div><strong>UF:</strong> ${data.uf}</div>
<div><strong>CEP:</strong> ${data.cep}</div>
<div><strong>Email:</strong> <a href="mailto:${data.email}">${data.email}</a></div>
<div><strong>Telefone:</strong> ${data.telefone}</div>
`;
container.innerHTML += `
<div><strong>Simples Nacional:</strong> ${data.simples.optante ? 'Sim' : 'Não'}</div>
<div><strong>Simei:</strong> ${data.simei.optante ? 'Sim' : 'Não'}</div>
`;
const statusElement = document.getElementById('status');
statusElement.textContent = 'Dados carregados com sucesso!';
statusElement.classList.add('ok');
}
loadCnpjData();