attendance fixsed

This commit is contained in:
Sibunnayak 2024-08-01 11:03:19 +05:30
parent 02f7e34fc6
commit 2df74b757d
2 changed files with 7 additions and 6 deletions

View File

@ -6,7 +6,8 @@ export const markAttendance = async (req, res) => {
const { date, time, location, notes } = req.body;
const userId = req.user._id;
const userType = req.userType;
// console.log(req.user);
// console.log(req.body);
// Parse the input date
const [year, month, day] = date.split("/");
const parsedDate = new Date(Date.UTC(year, month - 1, day));
@ -32,7 +33,7 @@ export const markAttendance = async (req, res) => {
const existingAttendance = await Attendance.findOne({
userId,
userType,
'records.date': {
"records.date": {
$gte: startOfDay,
$lte: endOfDay,
},
@ -75,7 +76,6 @@ export const markAttendance = async (req, res) => {
}
};
// Get attendance by user ID
export const getAttendanceByUser = async (req, res) => {
try {
@ -116,7 +116,7 @@ export const AdmingetAttendanceByUser = async (req, res) => {
const attendanceDoc = await Attendance.findOne({
userId: id,
}).populate("userId", "name email");
// console.log(attendanceDoc);
if (!attendanceDoc) {
return res.status(404).json({
success: false,
@ -131,6 +131,7 @@ export const AdmingetAttendanceByUser = async (req, res) => {
res.status(200).json({
success: true,
user: attendanceDoc.userId,
userType: attendanceDoc.userType,
attendance: paginatedRecords,
total_data: totalData,
});

View File

@ -191,7 +191,7 @@ export const getAllTerritoryManager = async (req, res) => {
}
const total = await TerritoryManager.countDocuments(filter);
const salesCoOrinators = await TerritoryManager.find(filter)
const territoryManager = await TerritoryManager.find(filter)
.limit(PAGE_SIZE)
.skip(PAGE_SIZE * page)
.sort({ createdAt: -1 });
@ -200,7 +200,7 @@ export const getAllTerritoryManager = async (req, res) => {
success: true,
total_data: total,
total_pages: Math.ceil(total / PAGE_SIZE),
salesCoOrinators,
territoryManager,
});
} catch (error) {
res.status(500).json({