Proposed Resolution:
${submissionB.proposal || 'Not provided.'}
`;
}
// --- NAVIGATION & TAB LOGIC ---
function switchTab(tabName) {
tabNavigation.querySelectorAll('.tab-button').forEach(btn => {
btn.classList.toggle('active', btn.dataset.tab === tabName);
});
tabContents.querySelectorAll('.tab-content').forEach(content => {
content.classList.toggle('active', content.id === `${tabName}-tab`);
});
updateNavButtons();
}
function navigateTabs(direction) {
currentTabIndex += direction;
if (currentTabIndex < 0) currentTabIndex = 0;
if (currentTabIndex >= tabs.length) currentTabIndex = tabs.length - 1;
switchTab(tabs[currentTabIndex]);
}
function updateNavButtons() {
prevBtn.disabled = currentTabIndex === 0;
prevBtn.classList.toggle('opacity-50', prevBtn.disabled);
prevBtn.classList.toggle('cursor-not-allowed', prevBtn.disabled);
nextBtn.disabled = currentTabIndex === tabs.length - 1;
nextBtn.classList.toggle('opacity-50', nextBtn.disabled);
nextBtn.classList.toggle('cursor-not-allowed', nextBtn.disabled);
}
// --- PDF GENERATION ---
function generatePDF() {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const { partyA, partyB, summary, amount, submissionA, submissionB } = mediationState;
doc.setFontSize(20);
doc.setFont("helvetica", "bold");
doc.text("Business Dispute Mediation Summary", doc.internal.pageSize.getWidth() / 2, 20, { align: 'center' });
doc.setFontSize(10);
doc.setFont("helvetica", "normal");
doc.text(`Generated on: ${new Date().toLocaleDateString()}`, doc.internal.pageSize.getWidth() / 2, 26, { align: 'center' });
doc.autoTable({
startY: 35,
head: [['Dispute Details']],
body: [
[{ content: `Party A: ${partyA}`}],
[{ content: `Party B: ${partyB}`}],
[{ content: `Amount in Dispute: $${amount.toFixed(2)}`}],
],
theme: 'grid',
headStyles: { fillColor: [41, 128, 185] },
});
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.text("Dispute Summary", 14, doc.autoTable.previous.finalY + 12);
doc.setFontSize(10);
doc.setFont("helvetica", "normal");
const summaryLines = doc.splitTextToSize(summary || 'Not provided.', 180);
doc.text(summaryLines, 14, doc.autoTable.previous.finalY + 18);
let lastY = doc.autoTable.previous.finalY + 18 + (summaryLines.length * 5);
doc.autoTable({
startY: lastY + 5,
head: [[`${partyA}'s Position`, `${partyB}'s Position`]],
body: [
[
{ content: 'Statement of Facts:\n' + (submissionA.statement || 'Not provided.'), styles: { cellWidth: 'wrap' } },
{ content: 'Statement of Facts:\n' + (submissionB.statement || 'Not provided.'), styles: { cellWidth: 'wrap' } }
],
[
{ content: 'Proposed Resolution:\n' + (submissionA.proposal || 'Not provided.'), styles: { cellWidth: 'wrap' } },
{ content: 'Proposed Resolution:\n' + (submissionB.proposal || 'Not provided.'), styles: { cellWidth: 'wrap' } }
]
],
theme: 'striped',
headStyles: { fillColor: [52, 73, 94] },
});
doc.save('Mediation_Summary.pdf');
}
// --- START THE APP ---
init();
});