Personalized Mind-Body Wellness Plan

Personalized Mind-Body

Wellness Plan

${item.details}

` }).join('')}

Disclaimer: This plan is for informational purposes. Consult with healthcare professionals for personalized medical advice, especially before making significant changes to your health routine.

`; }; const updateUI = () => { prevBtn.style.visibility = currentStep > 0 ? 'visible' : 'hidden'; navigationContainer.style.display = currentStep >= wellnessCategories.length ? 'none' : 'flex'; stepIndicator.textContent = `Step ${currentStep + 1} of ${wellnessCategories.length}`; }; const handleNavigate = (direction) => { if (direction === 1 && !validateAndStoreAnswer()) { alert('Please make a selection to continue.'); return; } currentStep += direction; renderStep(); }; const validateAndStoreAnswer = () => { const radioGroup = document.querySelector(`#step-${currentStep} input[type="radio"]`); if (radioGroup) { const selected = document.querySelector(`input[name="${radioGroup.name}"]:checked`); if (selected) { const category = wellnessCategories[currentStep]; const selection = selected.value; finalPlan[category] = PLAN_DATA[category].options[selection]; return true; } return false; } return true; }; const handlePdfDownload = () => { if (Object.keys(finalPlan).length === 0) return; const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFont('helvetica', 'bold').setFontSize(20); doc.text('Your Personalized Mind-Body Wellness Plan', 105, 20, { align: 'center' }); let yPos = 35; Object.keys(finalPlan).forEach(category => { const item = finalPlan[category]; if (yPos > 250) { doc.addPage(); yPos = 20; } doc.setFontSize(14).setFont('helvetica', 'bold').setTextColor('#4338ca'); doc.text(category, 14, yPos); yPos += 7; doc.setFontSize(12).setFont('helvetica', 'bold').setTextColor('#1e1b4b'); doc.text(item.name, 14, yPos); yPos += 6; doc.setFontSize(11).setFont('helvetica', 'normal').setTextColor('#475569'); const detailsLines = doc.splitTextToSize(item.details, 180); doc.text(detailsLines, 14, yPos); yPos += (detailsLines.length * 5) + 10; }); doc.save('My_Mind_Body_Plan.pdf'); }; // --- EVENT LISTENERS --- nextBtn.addEventListener('click', () => handleNavigate(1)); prevBtn.addEventListener('click', () => handleNavigate(-1)); wizardContainer.addEventListener('click', (e) => { if (e.target.id === 'download-pdf-btn') { handlePdfDownload(); } }); // --- INITIALIZATION --- renderStep(); });
Scroll to Top