Skip to content

Commit

Permalink
update userDashborad, ngoDashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Laxelspal committed Jun 19, 2024
1 parent 050325a commit ac1721b
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 53 deletions.
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const bodyParser = require("body-parser");
const path = require('path');
const app = express();


const moment = require('moment');
const hbs = require('nodemailer-express-handlebars');
const methodOverride = require('method-override');

const {transporter}=require("./helpers/emailHelpers")

Expand All @@ -16,6 +18,7 @@ const Admin=require("./model/admin")

app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));
app.use(methodOverride('_method'));

const NGO=require("./model/ngo")
const isAdmin=require("./middleware/isAdmin");
Expand Down
6 changes: 0 additions & 6 deletions public/css/ngo_dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ body.dark {
padding: 10px;
}

.Profile-sec {
display: flex;
padding: 9%;
justify-content: center;
align-content: center;
}

.dashboard {
display: inline-block;
Expand Down
Binary file added public/img/userProfile.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions routers/NgoRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ const Admin = require("../model/admin");
const NGO = require("../model/ngo");
const Query = require("../model/query"); // Adjust the path based on your project structure


router.post("/ngo",async(req,res)=>{
let {email,fullName,phoneNo,address} =req.body;
let id=req.query.id;
let ngo=await NGO.findByIdAndUpdate(id,{NGOName:fullName,Mobile:phoneNo,NgoLocation:address, username:email},{new:true});

const dooner = await User.find();
console.log(ngo);
return res.render("NGO-Dashboard", {
userId:ngo._id,
fullName: ngo.NGOName,
email: ngo.username,
id: ngo.NGOID,
phoneNo: ngo.Mobile,
address: ngo.NgoLocation,
Donation: dooner,
Pickup: dooner,
complain: "",
});
})

router.post("/NGO-login", async (req, res) => {
const username = req.body.username;
const password = req.body.password;
Expand All @@ -30,11 +51,12 @@ router.post("/NGO-login", async (req, res) => {
const dooner = await User.find(); // Assuming User is your Mongoose model for users

res.render("NGO-Dashboard", {
userId:ngo._id,
fullName: ngo.NGOName,
email: ngo.username,
id: ngo.NGOID,
phoneNo: ngo.Mobile,
address: ngo.NGOLocation,
address: ngo.NgoLocation,
Donation: dooner,
Pickup: dooner,
complain: "",
Expand Down Expand Up @@ -326,11 +348,12 @@ router.route("/reset-password-ngo").post(async (req, res) => {
const dooner = await User.find();

return res.render("NGO-DashBoard", {
userId:ngo._id,
fullName: ngo.NGOName,
email: ngo.username,
id: ngo.NGOID,
phoneNo: ngo.Mobile,
address: ngo.NGOLocation,
address: ngo.NgoLocation,
Donation: dooner,
Pickup: dooner,
complain: "",
Expand Down
34 changes: 34 additions & 0 deletions routers/userRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,33 @@ router.post("/", async function (req, res) {
}
});

router.post("/user",async(req,res)=>{
let {email,fullName,phoneNo,address} =req.body;
let id=req.query.id;
let foundUser=await User.findByIdAndUpdate(id,{fullName:fullName,phoneNo:phoneNo,address:address, email:email},{new:true});
// res.redirect("/login");
const userQuerys = await Query.find({ user_id: foundUser._id });

const donationInfo = {
food: foundUser.foodInventory,
city: foundUser.city,
flat: foundUser.flatNo,
destination: foundUser.destinaion,
acceptedBy: foundUser.acceptedBy,
status: foundUser.status,
};

return res.render("UserDashBoard", {
userId:foundUser._id,
fullName: foundUser.fullName,
email: foundUser.email,
phoneNo: foundUser.Mobile,
address: foundUser.address,
complain: userQuerys,
donationInfo: donationInfo,
});
})

// user login (seems to be something wrong here - user cant login even if he gives correct credentials)
router.post("/login", async function (req, res) {
const { username, password } = req.body;
Expand All @@ -98,6 +125,7 @@ router.post("/login", async function (req, res) {

if (result) {
return res.render("UserDashBoard", {
userId:foundUser._id,
fullName: foundUser.fullName,
email: foundUser.email,
phoneNo: foundUser.Mobile,
Expand Down Expand Up @@ -217,6 +245,7 @@ router.post("/approve-donation/:email/:ngoEmail", async (req, res) => {
const dooner = await User.find(); // Assuming User is your Mongoose model for users

res.render("NGO-Dashboard", {
userId:ngo._id,
fullName: ngo.NGOName,
email: ngo.username,
id: ngo.NGOID,
Expand Down Expand Up @@ -321,6 +350,7 @@ router.post("/User_singUp", async function (req, res) {
const userQuerys = await Query.find({ user_id: foundUser._id });

return res.render("UserDashBoard", {
userId:foundUser._id,
fullName: foundUser.fullName,
email: foundUser.email,
phoneNo: foundUser.Mobile,
Expand Down Expand Up @@ -465,6 +495,7 @@ router.route("/reset-password-user").post(async (req, res) => {
await user.save();
const userQuerys = await Query.find({ user_id: user._id });
return res.render("UserDashBoard", {
userId:user._id,
fullName: user.fullName,
email: user.email,
phoneNo: user.Mobile,
Expand Down Expand Up @@ -497,6 +528,7 @@ router.post("/delete-query/:id/:email", async (req, res) => {
const userQuerys = await Query.find({ user_id: foundUser._id });

return res.render("UserDashBoard", {
userId:foundUser._id,
fullName: foundUser.fullName,
email: foundUser.email,
phoneNo: foundUser.Mobile,
Expand Down Expand Up @@ -542,6 +574,7 @@ router.post("/donation-status/:email", async (req, res) => {
};
const userQuerys = await Query.find({ user_id: user._id });
return res.render("UserDashBoard", {
userId:user._id,
fullName: user.fullName,
email: user.email,
phoneNo: user.Mobile,
Expand All @@ -554,6 +587,7 @@ router.post("/donation-status/:email", async (req, res) => {
const ngo = await NGO.findOne({ NGOName: user.acceptedBy });

res.render("NGO-Dashboard", {
userId:user._id,
fullName: ngo.NGOName,
email: ngo.username,
id: ngo.NGOID,
Expand Down
106 changes: 95 additions & 11 deletions views/NGO-Dashboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,71 @@
<link rel="stylesheet" href="/css/ngo_dashboard.css">

<style>
/* Profile Section */
.Profile-sec{
display: flex;
justify-content: center;
align-items: center;
}
.user_img{
background-color: #FFF;
color: #000;
text-align: center;
border-radius: 1rem;
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
margin-bottom: 1rem;
padding-bottom: 1rem;
}
.user_info{
flex-grow: 1;
background-color: #FFF;
color: #000;
padding: 1rem;
border-radius: 1rem;
margin-bottom: 1rem;
width: 100%;
}
.middle {
display: flex;
flex-wrap: wrap;
width: 100%;
justify-content: space-between;
align-content: center;
padding: 4rem 2rem 7rem 19rem;
}
.img_box{
height:15rem;
width:17rem;
}
.img_box img{
height:14rem;
width:13rem;
border-radius: 10%;
}
.btn{
padding: 0.5rem;
background-color: green;
font-size: medium;
border-radius: 0.5rem;
font-weight: 400;
}
input[type="text"],
input[type="number"],
input[type="email"],
select {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 10px;
}
.progress-section {
width: 100%;
display: flex;
Expand Down Expand Up @@ -169,18 +234,37 @@
</div>
<hr class="top-border">
<section class="Profile-sec">
<div class="Donatebox">
<div class="NAME-block">
<h4 class="User-Name">Full Name: <%= fullName %>
</h4>
<h4 class="User-Email">Email: <%= email %>
</h4>
<h4 class="User-Phone">Phone No: <%= phoneNo %>
</h4>
<h4 class="User-Adderss">Address: <%= address %>
</h4>
<div class="middle">

<div class="user_img" >
<div class="">
<div class="img_box">
<img src="./img/userProfile.jpg" alt="">
</div>
<h2 style="margin-top: 1rem;"><%= fullName %></h2>
<h3><%= email %></h3>
</div>
</div>
<div class="" style="width: 10px;"></div>
<form action="/ngo?id=<%=userId%>" method="post" class="user_info">
<h3 class="" style="margin-bottom: 1rem;">User Info</h3>
<h4 class="User-Name">Name</h4>
<input type="text" value="<%=fullName%>" name="fullName">

<h4 class="User-Email">Email</h4>
<input type="email" value="<%=email%>" name="email">

<h4 class="User-Phone">Phone No</h4>
<input type="number" value="<%=phoneNo%>" name="phoneNo">
<h4 class="User-Address">Address</h4>
<input type="text" value="<%=address%>" name="address">
<br><br>
<button type="submit" class="btn">Edit Profile</button>

</form>

</div>
</div>

</section>
<section class="NGO-sec" style="display: none;">
<h2 style="text-align: center; margin-bottom: 2rem;">Pending Donation Pickup : <%= (Donation.filter(user=>
Expand Down
Loading

0 comments on commit ac1721b

Please sign in to comment.