Add special awards management features and fix voting/assignment issues
Special Awards: - Add delete button with confirmation dialog to award detail page - Add voting window dates (start/end) to award edit page - Add manual project eligibility management (add/remove projects) - Show eligibility method (Auto/Manual) in eligibility table - Auto-set votingStartAt when opening voting if date is in future Assignment Suggestions: - Replace toggle with proper tabs UI (Algorithm vs AI Powered) - Persist AI suggestions when navigating away (stored in database) - Show suggestion counts on tab badges - Independent refresh/start buttons per tab Round Voting: - Auto-update votingStartAt to now when activating round if date is in future - Fixes issue where round was opened but voting dates were in future Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -251,15 +251,31 @@ export const roundRouter = router({
|
||||
})
|
||||
)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
// Get previous status for audit
|
||||
// Get previous status and voting dates for audit
|
||||
const previousRound = await ctx.prisma.round.findUniqueOrThrow({
|
||||
where: { id: input.id },
|
||||
select: { status: true },
|
||||
select: { status: true, votingStartAt: true, votingEndAt: true },
|
||||
})
|
||||
|
||||
const now = new Date()
|
||||
|
||||
// When activating a round, if votingStartAt is in the future, update it to now
|
||||
// This ensures voting actually starts when the admin opens the round
|
||||
let votingStartAtUpdated = false
|
||||
const updateData: Parameters<typeof ctx.prisma.round.update>[0]['data'] = {
|
||||
status: input.status,
|
||||
}
|
||||
|
||||
if (input.status === 'ACTIVE' && previousRound.status !== 'ACTIVE') {
|
||||
if (previousRound.votingStartAt && previousRound.votingStartAt > now) {
|
||||
updateData.votingStartAt = now
|
||||
votingStartAtUpdated = true
|
||||
}
|
||||
}
|
||||
|
||||
const round = await ctx.prisma.round.update({
|
||||
where: { id: input.id },
|
||||
data: { status: input.status },
|
||||
data: updateData,
|
||||
})
|
||||
|
||||
// Map status to specific action name
|
||||
@@ -277,7 +293,15 @@ export const roundRouter = router({
|
||||
action,
|
||||
entityType: 'Round',
|
||||
entityId: input.id,
|
||||
detailsJson: { status: input.status, previousStatus: previousRound.status },
|
||||
detailsJson: {
|
||||
status: input.status,
|
||||
previousStatus: previousRound.status,
|
||||
...(votingStartAtUpdated && {
|
||||
votingStartAtUpdated: true,
|
||||
previousVotingStartAt: previousRound.votingStartAt,
|
||||
newVotingStartAt: now,
|
||||
}),
|
||||
},
|
||||
ipAddress: ctx.ip,
|
||||
userAgent: ctx.userAgent,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user