Add user tag editing and improve member error display
- Display actual error message in member detail page instead of generic Member not found - Add debug logging to user.get query to help diagnose issues - Add expertise tags editing for users in profile settings page - Update user.updateProfile mutation to accept expertiseTags Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -78,10 +78,11 @@ export const userRouter = router({
|
||||
bio: z.string().max(1000).optional(),
|
||||
phoneNumber: z.string().max(20).optional().nullable(),
|
||||
notificationPreference: z.enum(['EMAIL', 'WHATSAPP', 'BOTH', 'NONE']).optional(),
|
||||
expertiseTags: z.array(z.string()).max(15).optional(),
|
||||
})
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const { bio, ...directFields } = input
|
||||
const { bio, expertiseTags, ...directFields } = input
|
||||
|
||||
// If bio is provided, merge it into metadataJson
|
||||
let metadataJson: Prisma.InputJsonValue | undefined
|
||||
@@ -99,6 +100,7 @@ export const userRouter = router({
|
||||
data: {
|
||||
...directFields,
|
||||
...(metadataJson !== undefined && { metadataJson }),
|
||||
...(expertiseTags !== undefined && { expertiseTags }),
|
||||
},
|
||||
})
|
||||
}),
|
||||
@@ -241,14 +243,22 @@ export const userRouter = router({
|
||||
get: adminProcedure
|
||||
.input(z.object({ id: z.string() }))
|
||||
.query(async ({ ctx, input }) => {
|
||||
return ctx.prisma.user.findUniqueOrThrow({
|
||||
where: { id: input.id },
|
||||
include: {
|
||||
_count: {
|
||||
select: { assignments: true, mentorAssignments: true },
|
||||
console.log('[user.get] Fetching user:', input.id)
|
||||
try {
|
||||
const user = await ctx.prisma.user.findUniqueOrThrow({
|
||||
where: { id: input.id },
|
||||
include: {
|
||||
_count: {
|
||||
select: { assignments: true, mentorAssignments: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
console.log('[user.get] Found user:', user.email)
|
||||
return user
|
||||
} catch (error) {
|
||||
console.error('[user.get] Error fetching user:', input.id, error)
|
||||
throw error
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user