diff --git a/client/package-lock.json b/client/package-lock.json index e253aa45..954199a7 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -25,6 +25,7 @@ "chart.js": "^4.4.4", "flowbite-react": "^0.10.2", "framer-motion": "^11.11.1", + "fs": "^0.0.1-security", "indian_address": "^1.0.0", "indian-pincodes": "^1.1.0", "jspdf": "^2.5.2", @@ -14234,6 +14235,11 @@ "node": ">= 0.6" } }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "node_modules/fs-extra": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", diff --git a/client/package.json b/client/package.json index 15d12dd5..41251d4d 100644 --- a/client/package.json +++ b/client/package.json @@ -20,6 +20,7 @@ "chart.js": "^4.4.4", "flowbite-react": "^0.10.2", "framer-motion": "^11.11.1", + "fs": "^0.0.1-security", "indian_address": "^1.0.0", "indian-pincodes": "^1.1.0", "jspdf": "^2.5.2", diff --git a/client/src/pages/HospitalList.jsx b/client/src/pages/HospitalList.jsx index eed32a6a..8f4faa67 100644 --- a/client/src/pages/HospitalList.jsx +++ b/client/src/pages/HospitalList.jsx @@ -55,7 +55,7 @@ const HospitalsList = () => { try { let userId = user ? user._id : ''; const response = await axios.post( - databaseUrls.hospitals.bookHospital.replace('{_id}', hospitalId), + databaseUrls.hospitals.bookHospital.replace('_id', hospitalId), { userId, ...bookingData, diff --git a/client/src/pages/OPDRegistration.jsx b/client/src/pages/OPDRegistration.jsx index 8142b4ca..df649d3a 100644 --- a/client/src/pages/OPDRegistration.jsx +++ b/client/src/pages/OPDRegistration.jsx @@ -156,19 +156,85 @@ function OPDRegistrationForm() { const downloadPDF = () => { const doc = new jsPDF(); - doc.text('OPD Registration Details', 20, 20); - doc.text(`Name: ${registrationDetails.name}`, 20, 30); - doc.text(`Age: ${registrationDetails.age}`, 20, 40); + + // Add light cream background for main content + doc.setFillColor(252, 248, 230); // Light cream for body + doc.rect(0, 0, doc.internal.pageSize.width, doc.internal.pageSize.height, 'F'); + + // Add darker header background for logo + doc.setFillColor(41, 128, 185); // Professional blue for header + doc.rect(0, 0, doc.internal.pageSize.width, 45, 'F'); + + // Set text color to white for header content + doc.setTextColor(255, 255, 255); + + // Logo (add your base64 logo image here) + var img = new Image(); + img.src = '/1.png'; + doc.addImage(img, 'png', 85, 5, 40, 15); + + // Header text in white + doc.setFontSize(14); + doc.text('Hospital Appointment Confirmation', 105, 30, { align: 'center' }); + doc.setFontSize(10); + doc.text('Generated from Med-Space', 105, 36, { align: 'center' }); + + // Switch to dark text for body content + doc.setTextColor(44, 62, 80); // Dark blue-grey for better readability + + // Body + doc.setFontSize(12); + doc.text('OPD Registration Details', 20, 60); + doc.setDrawColor(41, 128, 185); // Blue line color + doc.line(20, 65, 190, 65); // Decorative line under section header + + doc.text(`Name: ${registrationDetails.name}`, 20, 75); + doc.text(`Age: ${registrationDetails.age}`, 20, 85); doc.text( - `Date of Appointment: ${appointmentDetails.appointment.date}`, - 20, - 50, + `Date of Appointment: ${appointmentDetails.appointment.date}`, + 20, + 95 ); - doc.text(`Reason: ${appointmentDetails.appointment.reason}`, 20, 60); - doc.text(`Hospital: ${appointmentDetails.hospital.name}`, 20, 70); + doc.text(`Reason: ${appointmentDetails.appointment.reason}`, 20, 105); + doc.text(`Hospital: ${appointmentDetails.hospital.name}`, 20, 115); + doc.text( + `Address: ${appointmentDetails.hospital.address.street}, ${appointmentDetails.hospital.address.city}, ${appointmentDetails.hospital.address.state}, ${appointmentDetails.hospital.address.postalCode}`, + 20, + 125 + ); + doc.text(`Contact: ${appointmentDetails.hospital.phone}`, 20, 135); + + // Footer with blue background + const pageCount = doc.internal.getNumberOfPages(); + doc.setFontSize(10); + for (let i = 1; i <= pageCount; i++) { + doc.setPage(i); + + // Add footer background + doc.setFillColor(41, 128, 185); + doc.rect(0, doc.internal.pageSize.height - 20, doc.internal.pageSize.width, 20, 'F'); + + // Footer text in white + doc.setTextColor(255, 255, 255); + doc.text( + `Page ${i} of ${pageCount}`, + doc.internal.pageSize.width / 2, + doc.internal.pageSize.height - 12, + { align: 'center' } + ); + doc.text( + 'Thank you for choosing Our Hospital. Please bring this document on the day of your appointment.\n 2024 Med-Space. All rights reserved.', + 105, + doc.internal.pageSize.height - 6, + { align: 'center' } + ); + } + + // Save PDF doc.save('appointment-details.pdf'); }; + return ( <>