Skip to content

Commit

Permalink
fixed registrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Luson045 committed Oct 28, 2024
1 parent 69a6bf8 commit 8dbd4bb
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 22 deletions.
6 changes: 6 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/HospitalList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
103 changes: 83 additions & 20 deletions client/src/pages/OPDRegistration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<div className={`${dark === 'dark' ? 'dark' : ''}`}>
Expand Down Expand Up @@ -354,18 +420,6 @@ function OPDRegistrationForm() {
/>
{errors.report && <span className="error">{errors.report}</span>}
</div>
<div className="form-group form-textarea">
<label htmlFor="reason">Reason:</label>
<textarea
id="reason"
name="reason"
placeholder="Enter the reason for your visit"
value={formData.reason}
onChange={handleChange}
required
></textarea>
{errors.reason && <span className="error">{errors.reason}</span>}
</div>

<div className="form-actions form-buttons">
<button
Expand Down Expand Up @@ -418,6 +472,15 @@ function OPDRegistrationForm() {
Hospital:{' '}
{appointmentDetails?.hospital?.name || 'City Hospital'}
</li>
<li>
Address:{' '}
{appointmentDetails?.hospital?.address.street || 'Null'},{appointmentDetails?.hospital?.address.city || 'Null'},{appointmentDetails?.hospital?.address.state || 'Null'}
</li>

<li>
Phone:{' '}
{appointmentDetails?.hospital?.phone || 'City Hospital'}
</li>
</ul>

<button
Expand Down
3 changes: 3 additions & 0 deletions server/controllers/appointments/appointmentsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mongoose = require("mongoose");
const { z } = require("zod");
const asyncHandler = require("express-async-handler");
const NodeGeocoder = require("node-geocoder");
const axios = require("axios");
const sendMail = require("../../utils/notifications/sendMail.js");
const {
appointmentSchema,
Expand Down Expand Up @@ -293,6 +294,8 @@ const addEmergencyAppointment = asyncHandler(async (req, res) => {
hospital: {
id: hospital._id,
name: hospital.name,
address: hospital.address,
phone: hospital.phone
},
});
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion server/utils/notifications/sendMail.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ const sendMail = (htmlContent, receiverEmail) => {
});
};

exports.sendMail = sendMail;
module.exports = sendMail;

0 comments on commit 8dbd4bb

Please sign in to comment.