Corrigindo Estúdio de Poesia: PDF, Inteligência de Idade e Botão Lixeira
This commit is contained in:
+49
-16
@@ -5294,19 +5294,34 @@ const initApp = () => {
|
||||
if (btnDownloadPoesiaPdf) {
|
||||
btnDownloadPoesiaPdf.addEventListener('click', () => {
|
||||
if (!currentPoesia) return;
|
||||
const element = document.createElement('div');
|
||||
element.innerHTML = window.marked ? marked.parse(currentPoesia) : currentPoesia;
|
||||
element.style.padding = '20px';
|
||||
element.style.fontFamily = 'Arial, sans-serif';
|
||||
element.style.color = '#333';
|
||||
|
||||
html2pdf().set({
|
||||
margin: 15,
|
||||
filename: 'poesia_pedagogica.pdf',
|
||||
image: { type: 'jpeg', quality: 0.98 },
|
||||
html2canvas: { scale: 2 },
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||
}).from(element).save();
|
||||
const printWindow = window.open('', '_blank');
|
||||
printWindow.document.write(`
|
||||
<html>
|
||||
<head>
|
||||
<title>Poesia - Assistente PedaGog</title>
|
||||
<style>
|
||||
body { font-family: 'Outfit', 'Inter', sans-serif; padding: 40px; color: #333; line-height: 1.6; }
|
||||
h1, h2, h3 { color: #10b981; margin-top: 24px; margin-bottom: 12px; }
|
||||
@media print {
|
||||
body { padding: 0; }
|
||||
button { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="max-width: 800px; margin: 0 auto;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 20px;">
|
||||
<h1 style="margin: 0; border: none; padding: 0;">📜 Poesia Pedagógica</h1>
|
||||
<button onclick="window.print()" style="background: #10b981; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: bold;">Imprimir / Salvar PDF</button>
|
||||
</div>
|
||||
<div>
|
||||
${window.marked ? marked.parse(currentPoesia) : currentPoesia}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
printWindow.document.close();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5327,16 +5342,34 @@ const initApp = () => {
|
||||
const date = new Date(item.created_at).toLocaleString('pt-BR');
|
||||
const div = document.createElement('div');
|
||||
div.className = 'history-item-card';
|
||||
div.style.cssText = 'background: rgba(255,255,255,0.02); padding: 14px; border-radius: 8px; border: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 8px; cursor: pointer;';
|
||||
div.style.cssText = 'background: rgba(255,255,255,0.02); padding: 14px; border-radius: 8px; border: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 8px; cursor: pointer; position: relative;';
|
||||
div.innerHTML = `
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; padding-right: 30px;">
|
||||
<strong style="color: var(--brand-green); font-size: 0.95rem;">${item.faixa_etaria} (${item.estrofes} Estrofes)</strong>
|
||||
<span style="font-size: 0.75rem; color: var(--text-secondary);">${date}</span>
|
||||
</div>
|
||||
<p style="margin: 0; font-size: 0.85rem; color: var(--text-primary); opacity: 0.9;">Tema: ${item.tema}</p>
|
||||
<button class="btn-delete-poesia" data-id="${item.id}" style="position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: #ef4444; cursor: pointer; font-size: 1.1rem; padding: 4px; border-radius: 4px;" title="Excluir Poesia">🗑️</button>
|
||||
`;
|
||||
|
||||
div.addEventListener('click', async () => {
|
||||
div.addEventListener('click', async (e) => {
|
||||
if (e.target.closest('.btn-delete-poesia')) {
|
||||
e.stopPropagation();
|
||||
if (confirm('Tem certeza que deseja excluir esta poesia?')) {
|
||||
try {
|
||||
const delRes = await fetch(`/api/poesias/${item.id}`, { method: 'DELETE' });
|
||||
if (delRes.ok) {
|
||||
showToast('Poesia excluída.', 'success');
|
||||
loadPoesiaHistory();
|
||||
} else {
|
||||
showToast('Erro ao excluir.', 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
showToast('Erro de conexão.', 'error');
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch(`/api/poesias/${item.id}`);
|
||||
const detail = await res.json();
|
||||
|
||||
Reference in New Issue
Block a user