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:
@@ -195,12 +195,28 @@ export const specialAwardRouter = router({
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const current = await ctx.prisma.specialAward.findUniqueOrThrow({
|
||||
where: { id: input.id },
|
||||
select: { status: true },
|
||||
select: { status: true, votingStartAt: true, votingEndAt: true },
|
||||
})
|
||||
|
||||
const now = new Date()
|
||||
|
||||
// When opening voting, auto-set votingStartAt to now if it's in the future or not set
|
||||
let votingStartAtUpdated = false
|
||||
const updateData: Parameters<typeof ctx.prisma.specialAward.update>[0]['data'] = {
|
||||
status: input.status,
|
||||
}
|
||||
|
||||
if (input.status === 'VOTING_OPEN' && current.status !== 'VOTING_OPEN') {
|
||||
// If no voting start date, or if it's in the future, set it to now
|
||||
if (!current.votingStartAt || current.votingStartAt > now) {
|
||||
updateData.votingStartAt = now
|
||||
votingStartAtUpdated = true
|
||||
}
|
||||
}
|
||||
|
||||
const award = await ctx.prisma.specialAward.update({
|
||||
where: { id: input.id },
|
||||
data: { status: input.status },
|
||||
data: updateData,
|
||||
})
|
||||
|
||||
await logAudit({
|
||||
@@ -211,6 +227,11 @@ export const specialAwardRouter = router({
|
||||
detailsJson: {
|
||||
previousStatus: current.status,
|
||||
newStatus: input.status,
|
||||
...(votingStartAtUpdated && {
|
||||
votingStartAtUpdated: true,
|
||||
previousVotingStartAt: current.votingStartAt,
|
||||
newVotingStartAt: now,
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user