Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved DonationInfo in userRoutes.js #212

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions routers/userRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ router.post("/User_singUp", async function (req, res) {
phoneNo: foundUser.Mobile,
address: foundUser.address,
complain: userQuerys,
donationInfo: donationInfo
});
} catch (error) {
console.error("Error during user registration:", error);
Expand Down Expand Up @@ -470,6 +471,7 @@ router.route("/reset-password-user").post(async (req, res) => {
phoneNo: user.Mobile,
address: user.address,
complain: userQuerys,
donationInfo: donationInfo
});

// Redirect to login page or any other desired page
Expand Down Expand Up @@ -502,6 +504,7 @@ router.post("/delete-query/:id/:email", async (req, res) => {
phoneNo: foundUser.Mobile,
address: foundUser.address,
complain: userQuerys,
donationInfo: donationInfo
});
} catch (error) {
console.error(error);
Expand Down
56 changes: 53 additions & 3 deletions views/UserDashBoard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,28 @@
font-size: 20px;
display: flex;
}
.certificate {
font-family: Arial, sans-serif;
border: 2px solid #000;
padding: 20px;
width: 600px;
margin: 50px auto;
text-align: center;
}

.certificate h1 {
font-size: 2em;
margin-bottom: 0.5em;
}

.certificate h2 {
font-size: 1.5em;
margin: 0.5em 0;
}

.certificate p {
margin: 0.5em 0;
}
/* Responsive Css */

@media (max-width: 980px) {
Expand Down Expand Up @@ -687,7 +708,7 @@
<div class="form-container">
<h2>Donation Form</h2>
<br>
<form id="donationForm" action="/add-details" method="post">
<form id="donationForm" method="post" onsubmit="generateCertificate(event)">
<label for="userId">Email Id:</label>
<input type="email" id="userId" name="email" required>
<span id="emailError" class="error"></span>
Expand Down Expand Up @@ -767,7 +788,7 @@
<button type="button" class="button" onclick="deleteRow()">Delete Row</button>
</div>
<div style="display: flex; justify-content: center;">
<button class="button" type="submit">Donate</button>
<button class="button" type="submit" >Donate</button>
</div>
</form>
</section>
Expand Down Expand Up @@ -1042,7 +1063,33 @@
alert("Cannot delete the only row");
}
}

//event hadler to get customised certificate
function generateCertificate(event) {
event.preventDefault();

const form = document.getElementById('donationForm');
const formData = new FormData(form);
const fullname='<%= fullName %>'
const foodItem = formData.get('foodItem');
const quantity = formData.get('quantity');

const certificateContent = `
<div class="certificate">
<h1>Certificate of Donation</h1>
<p>This certificate is proudly presented to</p>
<h2>${fullname}</h2>
<p>for their generous donation.</p>
<p>Food Item: ${foodItem} Food Quantity:${quantity}</p>
<p>Thank you for your support!</p>
</div>
`;

const certificateWindow = window.open('', '_blank');
certificateWindow.document.write(certificateContent);
//certificateWindow.document.close();
}

function validateForm() {
var isValid = true;

Expand Down Expand Up @@ -1179,8 +1226,11 @@
// four.classList.add("active");
// // five.classList.add("active");
// }

</script>



</body>

</html>