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({
user: updatedUser, data: {
message: isActive ? 'User enabled successfully' : 'User disabled successfully' user: updatedUser,
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({
user: updatedUser, data: {
message user: updatedUser,
message
}
}); });
} catch (error) { } catch (error) {
console.error('Error updating user role:', error); console.error('Error updating user role:', error);
@ -299,12 +303,14 @@ router.get('/users/:id/activity', async (req, res) => {
]); ]);
res.json({ res.json({
activities, data: {
pagination: { activities,
page, pagination: {
limit, page,
total, limit,
pages: Math.ceil(total / limit) || 0 total,
pages: Math.ceil(total / limit) || 0
}
} }
}); });
} catch (error) { } catch (error) {
@ -434,12 +440,14 @@ router.get('/activity', async (req, res) => {
const activities = await collection.aggregate(pipeline).toArray(); const activities = await collection.aggregate(pipeline).toArray();
res.json({ res.json({
activities, data: {
pagination: { activities,
page: validatedPage, pagination: {
limit: validatedLimit, page: validatedPage,
total, limit: validatedLimit,
pages: Math.ceil(total / validatedLimit) || 0 total,
pages: Math.ceil(total / validatedLimit) || 0
}
} }
}); });
} catch (error) { } catch (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({
settings: updatedSettings, data: {
message: 'Settings updated successfully' settings: updatedSettings,
message: 'Settings updated successfully'
}
}); });
} catch (error) { } catch (error) {
console.error('Error updating settings:', error); console.error('Error updating settings:', error);