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