fix: assign project to round on creation (create ProjectRoundState)
- Add optional roundId field to project.create mutation input schema - After project creation, update project.roundId FK and create a ProjectRoundState record (state: PENDING) when roundId is supplied - Pass selectedRoundId from the new-project form to createProject.mutate() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -484,6 +484,7 @@ export const projectRouter = router({
|
||||
.input(
|
||||
z.object({
|
||||
programId: z.string(),
|
||||
roundId: z.string().optional(),
|
||||
title: z.string().min(1).max(500),
|
||||
teamName: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
@@ -553,6 +554,20 @@ export const projectRouter = router({
|
||||
},
|
||||
})
|
||||
|
||||
if (input.roundId) {
|
||||
await tx.project.update({
|
||||
where: { id: created.id },
|
||||
data: { roundId: input.roundId },
|
||||
})
|
||||
await tx.projectRoundState.create({
|
||||
data: {
|
||||
projectId: created.id,
|
||||
roundId: input.roundId,
|
||||
state: 'PENDING',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Create team members if provided
|
||||
const inviteList: { userId: string; email: string; name: string }[] = []
|
||||
if (teamMembersInput && teamMembersInput.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user