add many to one in todo, fix bugs, notification about todos
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
|
||||
@@ -9,9 +9,16 @@ import { z } from 'zod';
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
* Všetky admin routes vyžadujú autentifikáciu a admin rolu
|
||||
* Routes accessible to all authenticated users
|
||||
*/
|
||||
router.use(authenticate);
|
||||
|
||||
// Zoznam všetkých userov (dostupné pre všetkých autentifikovaných používateľov)
|
||||
router.get('/users', adminController.getAllUsers);
|
||||
|
||||
/**
|
||||
* Admin-only routes
|
||||
*/
|
||||
router.use(requireAdmin);
|
||||
|
||||
/**
|
||||
@@ -21,9 +28,6 @@ router.use(requireAdmin);
|
||||
// Vytvorenie nového usera
|
||||
router.post('/users', validateBody(createUserSchema), adminController.createUser);
|
||||
|
||||
// Zoznam všetkých userov
|
||||
router.get('/users', adminController.getAllUsers);
|
||||
|
||||
// Získanie konkrétneho usera
|
||||
router.get(
|
||||
'/users/:userId',
|
||||
|
||||
Reference in New Issue
Block a user