Add image cropping to avatar upload and show avatars platform-wide
- Add react-easy-crop for circular crop + zoom UI on avatar upload - Create server-side getUserAvatarUrl utility for generating pre-signed URLs - Update all nav components (admin, jury, mentor, observer) to show user avatars - Add avatar URLs to user list, mentor list, and project detail API responses - Replace initials-only avatars with UserAvatar component across admin pages Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import type { Prisma } from '@prisma/client'
|
||||
import { router, protectedProcedure, adminProcedure, superAdminProcedure, publicProcedure } from '../trpc'
|
||||
import { sendInvitationEmail, sendMagicLinkEmail } from '@/lib/email'
|
||||
import { hashPassword, validatePassword } from '@/lib/password'
|
||||
import { attachAvatarUrls } from '@/server/utils/avatar-url'
|
||||
|
||||
const INVITE_TOKEN_EXPIRY_MS = 7 * 24 * 60 * 60 * 1000 // 7 days
|
||||
|
||||
@@ -204,6 +205,8 @@ export const userRouter = router({
|
||||
status: true,
|
||||
expertiseTags: true,
|
||||
maxAssignments: true,
|
||||
profileImageKey: true,
|
||||
profileImageProvider: true,
|
||||
createdAt: true,
|
||||
lastLoginAt: true,
|
||||
_count: {
|
||||
@@ -214,8 +217,10 @@ export const userRouter = router({
|
||||
ctx.prisma.user.count({ where }),
|
||||
])
|
||||
|
||||
const usersWithAvatars = await attachAvatarUrls(users)
|
||||
|
||||
return {
|
||||
users,
|
||||
users: usersWithAvatars,
|
||||
total,
|
||||
page,
|
||||
perPage,
|
||||
@@ -534,6 +539,8 @@ export const userRouter = router({
|
||||
name: true,
|
||||
expertiseTags: true,
|
||||
maxAssignments: true,
|
||||
profileImageKey: true,
|
||||
profileImageProvider: true,
|
||||
_count: {
|
||||
select: {
|
||||
assignments: input.roundId
|
||||
@@ -545,7 +552,7 @@ export const userRouter = router({
|
||||
orderBy: { name: 'asc' },
|
||||
})
|
||||
|
||||
return users.map((u) => ({
|
||||
const mapped = users.map((u) => ({
|
||||
...u,
|
||||
currentAssignments: u._count.assignments,
|
||||
availableSlots:
|
||||
@@ -553,6 +560,8 @@ export const userRouter = router({
|
||||
? Math.max(0, u.maxAssignments - u._count.assignments)
|
||||
: null,
|
||||
}))
|
||||
|
||||
return attachAvatarUrls(mapped)
|
||||
}),
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user