Tests, UX improvements.
This commit is contained in:
parent
4e6f5d36b8
commit
0ae18f495e
63 changed files with 1384 additions and 2330 deletions
|
|
@ -2,7 +2,7 @@ import Member from '../../../models/member.js'
|
|||
import { connectDB } from '../../../utils/mongoose.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireAdmin(event)
|
||||
const admin = await requireAdmin(event)
|
||||
|
||||
const body = await validateBody(event, adminMemberUpdateSchema)
|
||||
const memberId = getRouterParam(event, 'id')
|
||||
|
|
@ -30,6 +30,29 @@ export default defineEventHandler(async (event) => {
|
|||
status: body.status,
|
||||
}, { new: true })
|
||||
|
||||
// Log admin profile update
|
||||
const changedFields = []
|
||||
if (existing.name !== body.name) changedFields.push('name')
|
||||
if (existing.email !== body.email) changedFields.push('email')
|
||||
if (existing.circle !== body.circle) changedFields.push('circle')
|
||||
if (existing.contributionTier !== body.contributionTier) changedFields.push('contributionTier')
|
||||
if (existing.status !== body.status) changedFields.push('status')
|
||||
|
||||
if (changedFields.length) {
|
||||
logActivity(memberId, 'admin_profile_update', {
|
||||
fields: changedFields,
|
||||
changedBy: admin.name
|
||||
}, { performedBy: admin._id })
|
||||
}
|
||||
|
||||
// Log status change separately for admin-only visibility
|
||||
if (existing.status !== body.status) {
|
||||
logActivity(memberId, 'status_changed', {
|
||||
from: existing.status,
|
||||
to: body.status
|
||||
}, { performedBy: admin._id })
|
||||
}
|
||||
|
||||
return {
|
||||
_id: updated._id,
|
||||
name: updated.name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue