Update
This commit is contained in:
parent
5f0a19e0be
commit
a8492b7257
@ -93,6 +93,7 @@
|
||||
--admin-reject-btn: #F43030;
|
||||
--admin-reject-btn-hover: violet;
|
||||
--admin-reject-btn-active: black;
|
||||
--heading: #7C7C7C;
|
||||
}
|
||||
|
||||
body {
|
||||
@ -492,11 +493,30 @@ input:focus, textarea:focus, select:focus{
|
||||
.products p {
|
||||
font-family: osl;
|
||||
font-size: 25px;
|
||||
color: #7C7C7C;
|
||||
color: var(--heading);
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.profile a {
|
||||
font-family: osl;
|
||||
font-size: 25px;
|
||||
color: var(--product-page-info-btn);
|
||||
margin-bottom: 20px;
|
||||
margin-top: 20px;
|
||||
cursor: pointer;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.profile a:hover {
|
||||
color: var(--violet);
|
||||
}
|
||||
|
||||
.profile a:active {
|
||||
color: var(--white);
|
||||
transition: 0.1s;
|
||||
}
|
||||
|
||||
.product-list-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
function checkAuth(){
|
||||
firebase.auth().onAuthStateChanged(function(user){
|
||||
if (user) {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// https://javascript-minifier.com
|
||||
// @ts-nocheck
|
||||
function checkFields() {
|
||||
if (document.getElementById('pName').value && document.getElementById('pDesc').value
|
||||
&& document.getElementById('pLoc').value && document.getElementById('pPrice').value
|
||||
|
||||
@ -14,15 +14,15 @@
|
||||
<p>Price: £<%= item.price %></p>
|
||||
<div class="product-mgmt-buttons">
|
||||
<% var editbtnStyle = ""%>
|
||||
<% if (item.status == "sold") {editbtnStyle = "visibility:hidden;"} else {editbtnStyle = "visibility:all;"}%>
|
||||
<% if (item.status == "on-sale" || item.status == "off-sale") {editbtnStyle = "visibility:all;"} else {editbtnStyle = "visibility:hidden;"}%>
|
||||
<div class="edit-btn" style=<%= editbtnStyle%>><button onclick={edit_item()} id="editBtn">Edit</button> </div>
|
||||
<% var sellbtnText = "Place On Sale"%>
|
||||
<% var salebtnStyle = "visibility:hidden"%>
|
||||
<% if (item.status != "sold") {salebtnStyle = "visibility:all;"}%>
|
||||
<% if (item.status == "on-sale" || item.status == "off-sale") {salebtnStyle = "visibility:all;"}%>
|
||||
<% if (item.status == "on-sale") {sellbtnText = "Take Off Sale"}%>
|
||||
<div class="sell-btn" style="<%= salebtnStyle%>"><button onclick={toggle_sale()} id="toggleSaleBtn"><%= sellbtnText%></button> </div>
|
||||
<% var shipbtnStyle = ""%>
|
||||
<% if (item.status == "sold") {shipbtnStyle = "visibility:hidden;"} else {shipbtnStyle = "visibility:all;"}%>
|
||||
<% if (item.status != "on-sale") {shipbtnStyle = "visibility:hidden;"} else {shipbtnStyle = "visibility:all;"}%>
|
||||
<div class="ship-btn" style=<%= shipbtnStyle%>><button onclick={mark_as_sold()} id="soldBtn">Mark Sold</button> </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -8,6 +8,10 @@
|
||||
|
||||
<div class="space"></div>
|
||||
|
||||
<div class="profile">
|
||||
<a href="user-profile?dbid=<%= dbid %>">My Profile</a>
|
||||
</div>
|
||||
|
||||
<div class="products">
|
||||
<p>My products:</p>
|
||||
<div class="my-products-container">
|
||||
|
||||
9
package-lock.json
generated
9
package-lock.json
generated
@ -1426,6 +1426,15 @@
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
|
||||
"integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
|
||||
},
|
||||
"cookie-parser": {
|
||||
"version": "1.4.5",
|
||||
"resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.5.tgz",
|
||||
"integrity": "sha512-f13bPUj/gG/5mDr+xLmSxxDsB9DQiTIfhJS/sqjrmfAWiAN+x2O4i/XguTL9yDZ+/IFDanJ+5x7hC4CXT9Tdzw==",
|
||||
"requires": {
|
||||
"cookie": "0.4.0",
|
||||
"cookie-signature": "1.0.6"
|
||||
}
|
||||
},
|
||||
"cookie-signature": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"cookie-parser": "^1.4.5",
|
||||
"ejs": "^3.1.2",
|
||||
"express": "^4.17.1",
|
||||
"firebase": "^7.14.3",
|
||||
|
||||
27
server.js
27
server.js
@ -16,6 +16,10 @@ app.use(bodyParser.json())
|
||||
app.use(logger('dev'))
|
||||
app.use(express.static('views'))
|
||||
|
||||
const cookieParser = require('cookie-parser')();
|
||||
app.use(cookieParser);
|
||||
|
||||
|
||||
app.set('view engine', 'ejs')
|
||||
app.set('views', __dirname + '/views')
|
||||
|
||||
@ -29,6 +33,15 @@ let transporter = nodemailer.createTransport({
|
||||
})
|
||||
|
||||
|
||||
const validateFirebaseIdToken = (req, res, next) => {
|
||||
console.log("Running pre-function")
|
||||
console.log(req.cookies); //// <----- issue this is empty {} why??
|
||||
console.log("Finished pre function")
|
||||
next();
|
||||
};
|
||||
|
||||
app.use(validateFirebaseIdToken)
|
||||
|
||||
app.get("/", function(request, responce) {
|
||||
homePage(request, responce)
|
||||
})
|
||||
@ -115,10 +128,16 @@ app.get('/my-products', function(request, responce){
|
||||
})
|
||||
}
|
||||
else {
|
||||
dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){
|
||||
var data = {'x': {holder: '',id: 999,img: '',location: '',name: 'No products listed 😢',owner: '',price: '',stock: ''}}
|
||||
if (snapshot.val()) {data = snapshot.val()}
|
||||
responce.render('my-products.ejs', {products: data})
|
||||
let usersRef = database.ref("/users")
|
||||
usersRef.orderByChild("UID").equalTo(uid).once('value', function(snapshot){
|
||||
vals = snapshot.val()
|
||||
var keys = Object.keys(vals)
|
||||
sellerDBID = keys[0]
|
||||
dbRef.orderByChild('owner').equalTo(uid).once('value', function(snapshot){
|
||||
var data = {'x': {holder: '',id: 999,img: '',location: '',name: 'No products listed 😢',owner: '',price: '',stock: ''}}
|
||||
if (snapshot.val()) {data = snapshot.val()}
|
||||
responce.render('my-products.ejs', {products: data, dbid:sellerDBID})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user