Admin Dashboard Backend (Phases 1-4) #5

Merged
stephen merged 9 commits from admin into main 2026-01-22 14:11:43 -07:00
16 changed files with 11215 additions and 31 deletions
Showing only changes of commit f4c23d6b5b - Show all commits

View File

@ -164,8 +164,10 @@ router.patch('/users/:id', async (req, res) => {
});
res.json({
data: {
user: updatedUser,
message: isActive ? 'User enabled successfully' : 'User disabled successfully'
}
});
} catch (error) {
console.error('Error updating user status:', error);
@ -249,8 +251,10 @@ router.patch('/users/:id/role', async (req, res) => {
: 'User demoted to user successfully';
res.json({
data: {
user: updatedUser,
message
}
});
} catch (error) {
console.error('Error updating user role:', error);
@ -299,6 +303,7 @@ router.get('/users/:id/activity', async (req, res) => {
]);
res.json({
data: {
activities,
pagination: {
page,
@ -306,6 +311,7 @@ router.get('/users/:id/activity', async (req, res) => {
total,
pages: Math.ceil(total / limit) || 0
}
}
});
} catch (error) {
console.error('Error fetching user activity:', error);
@ -434,6 +440,7 @@ router.get('/activity', async (req, res) => {
const activities = await collection.aggregate(pipeline).toArray();
res.json({
data: {
activities,
pagination: {
page: validatedPage,
@ -441,6 +448,7 @@ router.get('/activity', async (req, res) => {
total,
pages: Math.ceil(total / validatedLimit) || 0
}
}
});
} catch (error) {
console.error('Error fetching activity:', error);
@ -1123,8 +1131,10 @@ router.patch('/settings', async (req, res) => {
const updatedSettings = await getSettings(db);
res.json({
data: {
settings: updatedSettings,
message: 'Settings updated successfully'
}
});
} catch (error) {
console.error('Error updating settings:', error);