-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Tarunag03/main
Added certification feature .. thank you for your contribution
- Loading branch information
Showing
6 changed files
with
317 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const express = require("express"); | ||
const router = express.Router(); | ||
const pdf = require('html-pdf'); | ||
//const PDFDocument = require('pdfkit'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const PDFDocument = require('pdfkit'); | ||
|
||
const User = require("../model/user"); | ||
const Donation = require("../model/donation"); | ||
const { METHODS } = require("http"); | ||
|
||
// Donation route to save donation details and generate certificate | ||
router.post("/donate", async (req, res) => { | ||
try { | ||
// Find the user by their email | ||
let user = await User.findOne({ email: req.body.email }); | ||
|
||
// If the user exists, update their details | ||
if (user) { | ||
// Update the user's details | ||
user.flatNo = req.body.flatNo; | ||
user.addressLine1 = req.body.addressLine1; | ||
user.addressLine2 = req.body.addressLine2; | ||
user.city = req.body.city; | ||
user.state = req.body.state; | ||
user.zip = req.body.zip; | ||
user.foodInventory.push({ | ||
foodItem: req.body.foodItem, | ||
quantity: req.body.quantity, | ||
}); | ||
let item=req.body.foodItem; | ||
let quantity=req.body.quantity; | ||
// Save the updated user document | ||
const saveDetails = await user.save(); | ||
if (saveDetails) { | ||
res.render('certificate', { userName: user.fullName,quantity:quantity,item:item }); | ||
} | ||
} | ||
} catch (error) { | ||
console.error("Error adding details:", error); | ||
res.status(500).json({ error: "Internal server error" }); | ||
} | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.