|
@@ -12,7 +12,7 @@ module.exports = {
|
|
|
Renders landingPage
|
|
Renders landingPage
|
|
|
*/
|
|
*/
|
|
|
landingPage: function(req, res){
|
|
landingPage: function(req, res){
|
|
|
- let activity = new Activity({
|
|
|
|
|
|
|
+ new Activity({
|
|
|
ipAddr: req.headers['x-forwarded-for'] || req.connection.remoteAddress,
|
|
ipAddr: req.headers['x-forwarded-for'] || req.connection.remoteAddress,
|
|
|
merchant: req.session.user,
|
|
merchant: req.session.user,
|
|
|
route: "landing",
|
|
route: "landing",
|
|
@@ -67,6 +67,7 @@ module.exports = {
|
|
|
.populate("inventory.ingredient")
|
|
.populate("inventory.ingredient")
|
|
|
.populate("recipes")
|
|
.populate("recipes")
|
|
|
.then(async (merchant)=>{
|
|
.then(async (merchant)=>{
|
|
|
|
|
+ console.log("merchant found");
|
|
|
let promiseArray = [];
|
|
let promiseArray = [];
|
|
|
if(merchant.pos === "clover"){
|
|
if(merchant.pos === "clover"){
|
|
|
const subscriptionCheck = axios.get(`${process.env.CLOVER_ADDRESS}/v3/apps/${process.env.SUBLINE_CLOVER_APPID}/merchants/${merchant.posId}/billing_info?access_token=${merchant.posAccessToken}`);
|
|
const subscriptionCheck = axios.get(`${process.env.CLOVER_ADDRESS}/v3/apps/${process.env.SUBLINE_CLOVER_APPID}/merchants/${merchant.posId}/billing_info?access_token=${merchant.posAccessToken}`);
|
|
@@ -160,6 +161,7 @@ module.exports = {
|
|
|
return Promise.all([merchant.save()].concat(promiseArray));
|
|
return Promise.all([merchant.save()].concat(promiseArray));
|
|
|
})
|
|
})
|
|
|
.then((response)=>{
|
|
.then((response)=>{
|
|
|
|
|
+ console.log("response after clover stuff");
|
|
|
let date = new Date();
|
|
let date = new Date();
|
|
|
let firstDay = new Date(date.getFullYear(), date.getMonth() - 1, 1);
|
|
let firstDay = new Date(date.getFullYear(), date.getMonth() - 1, 1);
|
|
|
|
|
|
|
@@ -175,6 +177,7 @@ module.exports = {
|
|
|
}}
|
|
}}
|
|
|
])
|
|
])
|
|
|
.then((transactions)=>{
|
|
.then((transactions)=>{
|
|
|
|
|
+ console.log("found all transactions");
|
|
|
response[0]._id = undefined;
|
|
response[0]._id = undefined;
|
|
|
response[0].posAccessToken = undefined;
|
|
response[0].posAccessToken = undefined;
|
|
|
response[0].lastUpdatedTime = undefined;
|
|
response[0].lastUpdatedTime = undefined;
|
|
@@ -182,9 +185,10 @@ module.exports = {
|
|
|
|
|
|
|
|
return res.render("dashboardPage/dashboard", {merchant: response[0], transactions: transactions});
|
|
return res.render("dashboardPage/dashboard", {merchant: response[0], transactions: transactions});
|
|
|
})
|
|
})
|
|
|
- .catch((err)=>{});
|
|
|
|
|
|
|
+ .catch((err)=>{console.log(err)});
|
|
|
})
|
|
})
|
|
|
.catch((err)=>{
|
|
.catch((err)=>{
|
|
|
|
|
+ console.log(err);
|
|
|
req.session.error = "ERROR: UNABLE TO RETRIEVE USER DATA";
|
|
req.session.error = "ERROR: UNABLE TO RETRIEVE USER DATA";
|
|
|
return res.redirect("/");
|
|
return res.redirect("/");
|
|
|
});
|
|
});
|