feat: Add user management APIs, status enum, enhanced notifications

- Add updateUser and resetUserPassword admin endpoints
- Change company status from boolean to enum (registered, lead, customer, inactive)
- Add 'important' event type to calendar validators and email templates
- Add 1-hour-before event notifications cron job
- Add 18:00 evening notifications for next-day events
- Add contact description field support
- Fix count() function usage in admin service
- Add SQL migrations for schema changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
richardtekula
2026-01-15 09:41:29 +01:00
parent 5d01fc9542
commit 70fa080455
13 changed files with 423 additions and 19 deletions

View File

@@ -125,6 +125,47 @@ export const changeUserRole = async (req, res, next) => {
}
};
/**
* Update user details (admin only)
* PATCH /api/admin/users/:userId
*/
export const updateUser = async (req, res, next) => {
const { userId } = req.params;
const { firstName, lastName } = req.body;
try {
const updated = await adminService.updateUser(userId, { firstName, lastName });
res.status(200).json({
success: true,
data: updated,
message: 'Používateľ bol aktualizovaný',
});
} catch (error) {
next(error);
}
};
/**
* Reset user password (admin only)
* POST /api/admin/users/:userId/reset-password
*/
export const resetUserPassword = async (req, res, next) => {
const { userId } = req.params;
try {
const result = await adminService.resetUserPassword(userId);
res.status(200).json({
success: true,
data: { tempPassword: result.tempPassword },
message: 'Heslo bolo resetované',
});
} catch (error) {
next(error);
}
};
/**
* Zmazanie usera (admin only)
* DELETE /api/admin/users/:userId