#app-aprovacao { font-family: sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #ddd; border-radius: 8px; }
.loading { color: #666; font-style: italic; }
.error { color: red; font-weight: bold; padding: 20px; background: #ffe6e6; }
.campo-box { margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.campo-titulo { font-weight: bold; font-size: 0.9em; color: #555; text-transform: uppercase; }
.campo-valor { font-size: 1.1em; white-space: pre-wrap; } /* pre-wrap mantém as quebras de linha */
.header-aprov { background: #f4f4f4; padding: 10px; border-radius: 5px; margin-bottom: 20px; }
Carregando dados da aprovação...
document.addEventListener("DOMContentLoaded", function() {
// 1. Pega o ID da URL (ex: ?id=123456)
const params = new URLSearchParams(window.location.search);
const id = params.get('id');
const statusDiv = document.getElementById('status-msg');
const contentDiv = document.getElementById('conteudo-real');
if (!id) {
statusDiv.className = 'error';
statusDiv.innerText = '⛔ Link inválido. Falta o código de identificação.';
return;
}
// 2. Busca os dados no seu Backend
// IMPORTANTE: O '/wp-json/...' é o padrão do WP.
fetch('/wp-json/aprovacao/v1/ler?id=' + id)
.then(response => {
if (!response.ok) throw new Error('Aprovação não encontrada ou expirada.');
return response.json();
})
.then(data => {
// 3. Preenche os dados na tela
document.getElementById('view-cliente').innerText = data.cliente || '-';
document.getElementById('view-data').innerText = data.data || '-';
document.getElementById('view-canais').innerText = data.canais || '-';
document.getElementById('view-legenda').innerText = data.legenda || '-';
document.getElementById('view-obs').innerText = data.obs || 'Nenhuma observação.';
const linkElem = document.getElementById('view-link');
if(data.link_midia) {
linkElem.href = data.link_midia;
linkElem.innerText = "Clique para ver a imagem/vídeo";
} else {
linkElem.innerText = "Sem link de mídia";
linkElem.removeAttribute('href');
}
// Mostra o conteúdo e esconde o carregando
statusDiv.style.display = 'none';
contentDiv.style.display = 'block';
})
.catch(error => {
statusDiv.className = 'error';
statusDiv.innerText = 'Erro: ' + error.message;
});
});