add many to one in todo, fix bugs, notification about todos

This commit is contained in:
richardtekula
2025-11-24 11:30:25 +01:00
parent 8fd8f991e8
commit 125e30338a
5 changed files with 381 additions and 24 deletions

View File

@@ -123,10 +123,8 @@ export const getAllUsers = async (req, res) => {
res.status(200).json({
success: true,
data: {
users: allUsers,
count: allUsers.length,
},
count: allUsers.length,
data: allUsers,
});
} catch (error) {
const errorResponse = formatErrorResponse(error, process.env.NODE_ENV === 'development');

View File

@@ -113,10 +113,12 @@ export const getAllTimeEntries = async (req, res) => {
export const getMonthlyTimeEntries = async (req, res) => {
try {
const userId = req.userId;
const userRole = req.user.role;
const targetUserId = userRole === 'admin' && req.query.userId ? req.query.userId : userId;
const { year, month } = req.params;
const entries = await timeTrackingService.getMonthlyTimeEntries(
userId,
targetUserId,
parseInt(year),
parseInt(month)
);
@@ -139,10 +141,12 @@ export const getMonthlyTimeEntries = async (req, res) => {
export const generateMonthlyTimesheet = async (req, res) => {
try {
const userId = req.userId;
const userRole = req.user.role;
const targetUserId = userRole === 'admin' && req.query.userId ? req.query.userId : userId;
const { year, month } = req.params;
const result = await timeTrackingService.generateMonthlyTimesheet(
userId,
targetUserId,
parseInt(year),
parseInt(month)
);
@@ -253,10 +257,12 @@ export const deleteTimeEntry = async (req, res) => {
export const getMonthlyStats = async (req, res) => {
try {
const userId = req.userId;
const userRole = req.user.role;
const targetUserId = userRole === 'admin' && req.query.userId ? req.query.userId : userId;
const { year, month } = req.params;
const stats = await timeTrackingService.getMonthlyStats(
userId,
targetUserId,
parseInt(year),
parseInt(month)
);