diff --git a/src/controllers/dashBoardController.js b/src/controllers/dashBoardController.js index 455bf3fc2..2f81a0a66 100644 --- a/src/controllers/dashBoardController.js +++ b/src/controllers/dashBoardController.js @@ -1,3 +1,6 @@ +import userProfile from 'models/userProfile'; +import actionItem from 'models/actionItem'; + /* eslint-disable quotes */ const path = require("path"); const fs = require("fs/promises"); @@ -7,6 +10,7 @@ const emailSender = require("../utilities/emailSender"); const AIPrompt = require("../models/weeklySummaryAIPrompt"); const User = require("../models/userProfile"); + const dashboardcontroller = function () { const dashboardhelper = dashboardHelperClosure(); const dashboarddata = function (req, res) { @@ -137,6 +141,26 @@ const dashboardcontroller = function () { .catch(error => res.status(400).send(error)); }; + //6th month and yearly anniversaries + const postTrophyIcon = function (req, res) { + console.log("API called with params:", req.params); + const userId = mongoose.Types.ObjectId(req.params.userId); + + userProfile.findById(userId, (err, record) => { + if (err || !record) { + res.status(404).send('No valid records found'); + return; + } + record.trophyFollowedUp = req.params.trophyFollowedUp; + + record.save() + .then((results) => { + res.status(200).send(results); + }) + .catch((error) => res.status(404).send(error)); + }); + }; + const orgData = function (req, res) { const fullOrgData = dashboardhelper.getOrgData(); @@ -330,6 +354,7 @@ const dashboardcontroller = function () { } }; + return { dashboarddata, getAIPrompt, @@ -344,6 +369,7 @@ const dashboardcontroller = function () { sendMakeSuggestion, updateCopiedPrompt, getPromptCopiedDate, + postTrophyIcon, }; }; diff --git a/src/helpers/dashboardhelper.js b/src/helpers/dashboardhelper.js index 533dbe367..7bab6df34 100644 --- a/src/helpers/dashboardhelper.js +++ b/src/helpers/dashboardhelper.js @@ -203,6 +203,8 @@ const dashboardhelper = function () { timeOffFrom: 1, timeOffTill: 1, endDate: 1, + createdDate: 1, + trophyFollowedUp: 1, } ); @@ -220,7 +222,8 @@ const dashboardhelper = function () { timeOffFrom: 1, timeOffTill: 1, endDate: 1, - + createdDate: 1, + trophyFollowedUp: 1, }, ); } @@ -286,6 +289,8 @@ const dashboardhelper = function () { timeOffFrom: teamMember.timeOffFrom || null, timeOffTill: teamMember.timeOffTill || null, endDate: teamMember.endDate || null, + createdDate: teamMember.createdDate || null, + trophyFollowedUp: teamMember.trophyFollowedUp || false, }; leaderBoardData.push(obj); }); @@ -601,6 +606,8 @@ const dashboardhelper = function () { personId: userId, role: user.role, isVisible: user.isVisible, + createdDate: user.createdDate, + trophyFollowedUp: user.trophyFollowedUp, hasSummary: user.weeklySummaries[0].summary !== '', weeklycommittedHours: user.weeklycommittedHours, name: `${user.firstName} ${user.lastName}`, diff --git a/src/helpers/reporthelper.js b/src/helpers/reporthelper.js index 6e874035f..ddc6292b4 100644 --- a/src/helpers/reporthelper.js +++ b/src/helpers/reporthelper.js @@ -85,6 +85,7 @@ const reporthelper = function () { weeklySummaryOption: 1, adminLinks: 1, bioPosted: 1, + toggleTrophyIcon: 1, badgeCollection: { $filter: { input: "$badgeCollection", diff --git a/src/models/userProfile.js b/src/models/userProfile.js index cc7136f54..71c0fd259 100644 --- a/src/models/userProfile.js +++ b/src/models/userProfile.js @@ -229,6 +229,7 @@ const userProfileSchema = new Schema({ isVisible: { type: Boolean, default: true }, weeklySummaryOption: { type: String }, bioPosted: { type: String, default: 'default' }, + trophyFollowedUp: { type: Boolean, default: false }, isFirstTimelog: { type: Boolean, default: true }, badgeCount: { type: Number, default: 0 }, teamCode: { diff --git a/src/routes/dashboardRouter.js b/src/routes/dashboardRouter.js index d623815c0..48148669f 100644 --- a/src/routes/dashboardRouter.js +++ b/src/routes/dashboardRouter.js @@ -28,6 +28,9 @@ const route = function () { Dashboardrouter.route('/dashboard/leaderboard/org/data') .get(controller.orgData); + Dashboardrouter.route('/dashboard/leaderboard/trophyIcon/:userId/:trophyFollowedUp') + .post(controller.postTrophyIcon); + Dashboardrouter.route('/dashboard/suggestionoption/:userId') .get(controller.getSuggestionOption);