Skip to content

Commit

Permalink
Navbar Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
iampavangandhi committed Aug 28, 2020
1 parent 5dfefbb commit 5102630
Show file tree
Hide file tree
Showing 9 changed files with 500 additions and 427 deletions.
6 changes: 3 additions & 3 deletions config/data-compact.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"Symbol": "AAPL"
},
{
"Company Name": "Adobe Systems Incorporated",
"Company Name": "Adobe Systems",
"Symbol": "ADBE"
},
{
"Company Name": "Advent Software, Inc.",
"Symbol": "ADVS"
},
{
"Company Name": "Advanced Micro Devices, Inc.",
"Company Name": "Advance Micro Devices",
"Symbol": "AMD"
},
{
Expand Down Expand Up @@ -60,7 +60,7 @@
"Symbol": "NVDA"
},
{
"Company Name": "QUALCOMM Incorporated",
"Company Name": "Qualcomm, Inc.",
"Symbol": "QCOM"
},
{
Expand Down
2 changes: 1 addition & 1 deletion public/css/style.css

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions public/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ body {
.user-profile {
border-radius: 100px;
border: 10px solid #1955e4;
width: 130px;
height: 130px;
}

.tick {
Expand Down Expand Up @@ -105,11 +103,11 @@ body {

.notification .badge {
position: absolute;
top: -10px;
right: -10px;
top: -5px;
right: -5px;
padding: 5px 2px;
border-radius: 50%;
background-color: #1955e4;
background-color: #0072ff;
color: white;
}

Expand Down
105 changes: 50 additions & 55 deletions routes/api/edit.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,59 @@
// Edit Profile Route
const express = require('express')
const router = express.Router()
const { ensureAuth } = require('../../middleware/auth')

const User = require('../../models/User.js');
const { id } = require('date-fns/locale');
const { last } = require('lodash');

const express = require("express");
const router = express.Router();
const { ensureAuth } = require("../../middleware/auth");

const User = require("../../models/User.js");

// @desc Show edit page
// @route GET /edit/:id
// @route GET /edit
router.get("/", ensureAuth, (req, res) => {
let avatar = req.user.image;

let firstName = req.user.firstName;
let lastName = req.user.lastName;
let email = req.user.email;


console.log(avatar);


res.status(200).render("edit", {
layout: "layouts/app",
avatar,
firstName,
lastName,
email,
href: "/edit",
});
let avatar = req.user.image;

let displayName = req.user.displayName;
let firstName = req.user.firstName;
let lastName = req.user.lastName;
let email = req.user.email;

res.status(200).render("edit", {
layout: "layouts/app",
avatar,
displayName,
firstName,
lastName,
email,
href: "/edit",
});
});

router.put("/", ensureAuth, async(req, res) => {
try {


let curruser1 = await User.findById(req.user._id).lean();
console.log(curruser1);

curruser1.firstName = req.body.firstName;
curruser1.lastName = req.body.lastName;
curruser1.email = req.body.email;
curruser1.displayName = curruser1.firstName + " " + curruser1.lastName

curruser1 = await User.findOneAndUpdate({ _id: curruser1._id }, {
firstName: curruser1.firstName,
lastName: curruser1.lastName,
email: curruser1.email,
displayName: curruser1.displayName,
}, {
new: true, // it will create a new one, if it doesn't exist
runValidators: true, // it check weather the fields are valid or not
});

res.redirect("/portfolio");
} catch (err) {
console.error(err)
return res.render('error/500')
}
router.put("/", ensureAuth, async (req, res) => {
try {
let curruser1 = await User.findById(req.user._id).lean();

curruser1.displayName = req.body.displayName;
curruser1.firstName = req.body.firstName;
curruser1.lastName = req.body.lastName;
curruser1.email = req.body.email;

curruser1 = await User.findOneAndUpdate(
{ _id: curruser1._id },
{
firstName: curruser1.firstName,
lastName: curruser1.lastName,
email: curruser1.email,
displayName: curruser1.displayName,
},
{
new: true, // it will create a new one, if it doesn't exist
runValidators: true, // it check weather the fields are valid or not
}
);

res.redirect("/portfolio");
} catch (err) {
console.error(err);
return res.render("error/500");
}
});

module.exports = router;
module.exports = router;
8 changes: 4 additions & 4 deletions routes/api/market.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const totalData = require("../../config/data-total.json");
// @access Private
router.get("/", ensureAuth, async (req, res) => {
let min = 0;
let max = 75;
let max = 50;

res.status(200).render("market", {
layout: "layouts/app",
Expand All @@ -34,10 +34,10 @@ router.get("/", ensureAuth, async (req, res) => {
// @access Private
router.get("/:page", ensureAuth, async (req, res) => {
let page = req.params.page - 1;
let min = page * 75;
let max = page * 75 + 75;
let min = page * 50;
let max = page * 50 + 50;

if (page <= 0 || page >= 39) {
if (page <= 0 || page >= 59) {
res.status(200).redirect("/market");
} else {
res.status(200).render("market", {
Expand Down
149 changes: 98 additions & 51 deletions views/edit.ejs
Original file line number Diff line number Diff line change
@@ -1,64 +1,111 @@
<main class="md:col-span-4 md:ml-56 lg:ml-64 md:pr-14 w-full">
<div class="container px-5 py-10 mx-auto md:px-auto ">
<!-- header -->
<div class="container px-5 py-10 mx-auto md:px-auto">
<!-- header -->

<header class="my-4 absolute-center">
<span class="text-gray-700 text-3xl font-semibold leading-none tracking-wider">Edit Profile</span
<header class="my-4 absolute-center">
<span
class="text-gray-700 text-3xl font-semibold leading-none tracking-wider"
>Edit Profile</span
>
</header>

<hr class="line my-4" />

<!--form -->
<!--form -->

<form action="/edit" method="POST" class="w-full max-w-sm m-auto">
<input type="hidden" name="_method" value="PUT" />
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label
class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4"
for="inline-full-name"
>
Display :
</label>
</div>
<div class="md:w-2/3">
<input
type="text"
id="displayName"
name="displayName"
value="<%=displayName%>"
class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500"
/>
</div>
</div>
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label
class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4"
for="inline-full-name"
>
First Name :
</label>
</div>
<div class="md:w-2/3">
<input
type="text"
name="firstName"
value="<%=firstName%>"
class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500"
/>
</div>
</div>
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label
class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4"
for="inline-full-name"
>
Last Name :
</label>
</div>
<div class="md:w-2/3">
<input
type="text"
id="lastName"
name="lastName"
value="<%=lastName%>"
class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500"
/>
</div>
</div>
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label
class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4"
for="inline-full-name"
>
Email :
</label>
</div>
<div class="md:w-2/3">
<input
class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500"
type="email"
id="email"
name="email"
value="<%=email%>"
/>
</div>
</div>

<form action="/edit" method="POST" class="w-full max-w-sm m-auto">
<input type="hidden" name="_method" value="PUT">
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4" for="inline-full-name">
First Name :
</label>
</div>
<div class="md:w-2/3">
<input type="text" name="firstName" value="<%=firstName%>" class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" />
<!-- <input class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="inline-full-name" type="text" value="Jane Doe"> -->
</div>
</div>
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4" for="inline-full-name">
Last Name :
</label>
</div>
<div class="md:w-2/3">
<input type="text" id="lastName" name="lastName" value="<%=lastName%>" class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500">
<!-- <input class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="inline-full-name" type="text" value="Jane Doe"> -->
</div>
</div>
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4 mr-4" for="inline-full-name">
Email :
</label>
</div>
<div class="md:w-2/3">
<input class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" type="email" id="email" name="email" value="<%=email%>">
<!-- <input class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="inline-full-name" type="text" value="Jane Doe"> -->
</div>
</div>
<div class="md:flex justify-center">
<input
type="submit"
value="Save"
class="save_btn ml-6 cursor-pointer lg:ml-24 btn mb-4 shadow bg-blue-700 hover:bg-blue-800 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded"
/>


<div class="md:flex justify-center">
<!-- <div class="md:w-1/2"> -->
<input type="submit" value="Save" class="save_btn ml-6 cursor-pointer lg:ml-24 btn mb-4 shadow bg-blue-700 hover:bg-blue-800 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded">
<!-- </div> -->
<!-- <div class="md:w-1/2"> -->
<button class="mb-4 ml-6 shadow bg-yellow-500 hover:bg-yellow-600 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded" type="button" style="margin-left: 6px;">
<button
class="mb-4 ml-6 shadow bg-yellow-500 hover:bg-yellow-600 focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded"
type="button"
style="margin-left: 6px"
>
<a href="/portfolio">Cancel</a>
</button>
<!-- </div> -->
</div>
</div>
</form>
</div>
</main>
</div>
</main>
Loading

0 comments on commit 5102630

Please sign in to comment.