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

Updated user Dashboard #219

Closed
wants to merge 4 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 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
81 changes: 67 additions & 14 deletions public/css/ngo_dashboard.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
body {
min-height: 100vh;
background-color: var(--primary-color);
transition: background-color var(--tran-03);
margin: 0;
font-family: "Poppins", sans-serif;
background-color: #e7e5e586;
}
.uil{
font-size: 1.5rem;
}
.nav-links {
padding: 0rem 1rem;
}

.logout-mode{
padding-left: 1.2rem;
}

/* Edit Form */
.Edit_profile{
display: none;
justify-content: center;
align-items: center;
}
.edit_header{
text-align: center;
margin-bottom: 1rem;
}
.Edit_profile h4{
margin-bottom: 7px;
}
.Edit_profile button{
padding: 0.6rem 2rem;
border-radius: 10px;
margin: 1rem 0rem;
cursor: pointer;
font-size: medium;
border: 0;
}
.update-btn{
background-color: orange;

}
.cancle-btn{
background-color: #3e8e41;
}
.edit-btns{
display: flex;
justify-content: space-between;
}

body.dark {
Expand Down Expand Up @@ -37,6 +80,7 @@ body.dark {
border-radius: 12%;
}


.NAME-block {
display: flex;
gap: 5px;
Expand All @@ -54,28 +98,25 @@ body.dark {
.top-border {
border-style: double;
border-color: #f07070;

}

.Left-name {
font-weight: 500;
font-size: 20px;
display: inline-block;
position: absolute;
right: 3%;
padding-top: 3px;

}

.top {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
padding: 1.2rem 1rem;
}

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

.dashboard {
display: inline-block;
Expand Down Expand Up @@ -104,7 +145,7 @@ body.dark {

.dash {
position: fixed;
left: 35px;
left: 80px;
}

/* aditya End */
Expand All @@ -126,8 +167,10 @@ body.dark {
}

nav .logo-name {
text-decoration: none;
display: flex;
align-items: center;
padding: 1rem 0rem 1rem 0rem;
}

nav .logo-img {
Expand All @@ -150,7 +193,7 @@ nav .logo-name .logo_name {
}

nav .menu-items {
margin-top: 40px;
margin-top: 10px;
height: calc(100% - 90px);
display: flex;
flex-direction: column;
Expand All @@ -162,24 +205,30 @@ nav .menu-items {
}

.menu-items li a {
color :#242526;
display: flex;
align-items: center;
height: 50px;
text-decoration: none;
position: relative;
}
.manu-items li a:hover{
background-color: #d8d6d6;
border-radius: 10px;
}

.nav-links li a:hover:before {
content: "";
position: absolute;
height: 5px;
width: 5px;
border-radius: 50%;
background-color: var(--primary-color);
/* background-color: var(--primary-color); */
left: -7px;
}

.menu-items li {
margin-bottom: 1rem;
list-style: none;
}

Expand All @@ -195,8 +244,8 @@ nav .menu-items {

.menu-items li a .link-name {
font-size: 18px;
font-weight: 400;
color: green;
font-weight: 600;

}

.nav-links li a:hover i,
Expand Down Expand Up @@ -247,6 +296,10 @@ body.dark .switch::before {
}

body.dark .Profile-sec {
background-color: #5b5a5a;
color: #fff;
}
body.dark .Profile-sec .card {
background-color: #333;
color: #fff;
}
Expand Down
Binary file added public/img/user.ico
Binary file not shown.
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.
33 changes: 31 additions & 2 deletions routers/NgoRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,33 @@ 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/:id",async(req,res)=>{
let deletedngo=await NGO.findByIdAndDelete(req.params.id);
console.log(deletedngo);
res.redirect("/")
})

router.post("/NGO-login", async (req, res) => {
const username = req.body.username;
const password = req.body.password;
Expand All @@ -30,11 +57,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 +354,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
42 changes: 42 additions & 0 deletions routers/userRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,41 @@ router.post("/", async function (req, res) {
}
});


router.post("/user",async(req,res)=>{
let {email,fullName,phoneNo,address} =req.body;
console.log(req.body);
let id=req.query.id;
let foundUser=await User.findByIdAndUpdate(id,{fullName:fullName,Mobile: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,
});
})

router.post("/user/:id",async (req,res)=>{
// console.log(req.params.id);
await User.findByIdAndDelete(req.params.id);
return res.redirect("/");
})

// 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 +133,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 +253,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 +358,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 +503,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 +536,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 +582,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 +595,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
Loading