Round system redesign: Phases 1-7 complete
Full pipeline/track/stage architecture replacing the legacy round system. Schema: 11 new models (Pipeline, Track, Stage, StageTransition, ProjectStageState, RoutingRule, Cohort, CohortProject, LiveProgressCursor, OverrideAction, AudienceVoter) + 8 new enums. Backend: 9 new routers (pipeline, stage, routing, stageFiltering, stageAssignment, cohort, live, decision, award) + 6 new services (stage-engine, routing-engine, stage-filtering, stage-assignment, stage-notifications, live-control). Frontend: Pipeline wizard (17 components), jury stage pages (7), applicant pipeline pages (3), public stage pages (2), admin pipeline pages (5), shared stage components (3), SSE route, live hook. Phase 6 refit: 23 routers/services migrated from roundId to stageId, all frontend components refitted. Deleted round.ts (985 lines), roundTemplate.ts, round-helpers.ts, round-settings.ts, round-type-settings.tsx, 10 legacy admin pages, 7 legacy jury pages, 3 legacy dialogs. Phase 7 validation: 36 tests (10 unit + 8 integration files) all passing, TypeScript 0 errors, Next.js build succeeds, 13 integrity checks, legacy symbol sweep clean, auto-seed on first Docker startup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -64,12 +64,12 @@ import {
|
||||
import { toast } from 'sonner'
|
||||
import { formatDate } from '@/lib/utils'
|
||||
|
||||
type RecipientType = 'ALL' | 'ROLE' | 'ROUND_JURY' | 'PROGRAM_TEAM' | 'USER'
|
||||
type RecipientType = 'ALL' | 'ROLE' | 'STAGE_JURY' | 'PROGRAM_TEAM' | 'USER'
|
||||
|
||||
const RECIPIENT_TYPE_OPTIONS: { value: RecipientType; label: string }[] = [
|
||||
{ value: 'ALL', label: 'All Users' },
|
||||
{ value: 'ROLE', label: 'By Role' },
|
||||
{ value: 'ROUND_JURY', label: 'Round Jury' },
|
||||
{ value: 'STAGE_JURY', label: 'Stage Jury' },
|
||||
{ value: 'PROGRAM_TEAM', label: 'Program Team' },
|
||||
{ value: 'USER', label: 'Specific User' },
|
||||
]
|
||||
@@ -79,7 +79,7 @@ const ROLES = ['JURY_MEMBER', 'MENTOR', 'OBSERVER', 'APPLICANT', 'PROGRAM_ADMIN'
|
||||
export default function MessagesPage() {
|
||||
const [recipientType, setRecipientType] = useState<RecipientType>('ALL')
|
||||
const [selectedRole, setSelectedRole] = useState('')
|
||||
const [roundId, setRoundId] = useState('')
|
||||
const [stageId, setStageId] = useState('')
|
||||
const [selectedProgramId, setSelectedProgramId] = useState('')
|
||||
const [selectedUserId, setSelectedUserId] = useState('')
|
||||
const [subject, setSubject] = useState('')
|
||||
@@ -93,8 +93,11 @@ export default function MessagesPage() {
|
||||
const utils = trpc.useUtils()
|
||||
|
||||
// Fetch supporting data
|
||||
const { data: rounds } = trpc.round.listAll.useQuery()
|
||||
const { data: programs } = trpc.program.list.useQuery()
|
||||
// Get programs with stages
|
||||
const { data: programs } = trpc.program.list.useQuery({ includeStages: true })
|
||||
const rounds = programs?.flatMap((p) =>
|
||||
((p.stages ?? []) as Array<{ id: string; name: string }>).map((s: { id: string; name: string }) => ({ ...s, program: { name: p.name } }))
|
||||
) || []
|
||||
const { data: templates } = trpc.message.listTemplates.useQuery()
|
||||
const { data: users } = trpc.user.list.useQuery(
|
||||
{ page: 1, perPage: 100 },
|
||||
@@ -121,7 +124,7 @@ export default function MessagesPage() {
|
||||
setBody('')
|
||||
setSelectedTemplateId('')
|
||||
setSelectedRole('')
|
||||
setRoundId('')
|
||||
setStageId('')
|
||||
setSelectedProgramId('')
|
||||
setSelectedUserId('')
|
||||
setIsScheduled(false)
|
||||
@@ -170,14 +173,14 @@ export default function MessagesPage() {
|
||||
const roleLabel = selectedRole ? selectedRole.replace(/_/g, ' ') : ''
|
||||
return roleLabel ? `All ${roleLabel}s` : 'By Role (none selected)'
|
||||
}
|
||||
case 'ROUND_JURY': {
|
||||
if (!roundId) return 'Round Jury (none selected)'
|
||||
const round = (rounds as Array<{ id: string; name: string; program?: { name: string } }> | undefined)?.find(
|
||||
(r) => r.id === roundId
|
||||
case 'STAGE_JURY': {
|
||||
if (!stageId) return 'Stage Jury (none selected)'
|
||||
const stage = rounds?.find(
|
||||
(r) => r.id === stageId
|
||||
)
|
||||
return round
|
||||
? `Jury of ${round.program ? `${round.program.name} - ` : ''}${round.name}`
|
||||
: 'Round Jury'
|
||||
return stage
|
||||
? `Jury of ${stage.program ? `${stage.program.name} - ` : ''}${stage.name}`
|
||||
: 'Stage Jury'
|
||||
}
|
||||
case 'PROGRAM_TEAM': {
|
||||
if (!selectedProgramId) return 'Program Team (none selected)'
|
||||
@@ -214,8 +217,8 @@ export default function MessagesPage() {
|
||||
toast.error('Please select a role')
|
||||
return
|
||||
}
|
||||
if (recipientType === 'ROUND_JURY' && !roundId) {
|
||||
toast.error('Please select a round')
|
||||
if (recipientType === 'STAGE_JURY' && !stageId) {
|
||||
toast.error('Please select a stage')
|
||||
return
|
||||
}
|
||||
if (recipientType === 'PROGRAM_TEAM' && !selectedProgramId) {
|
||||
@@ -234,7 +237,7 @@ export default function MessagesPage() {
|
||||
sendMutation.mutate({
|
||||
recipientType,
|
||||
recipientFilter: buildRecipientFilter(),
|
||||
roundId: roundId || undefined,
|
||||
stageId: stageId || undefined,
|
||||
subject: subject.trim(),
|
||||
body: body.trim(),
|
||||
deliveryChannels,
|
||||
@@ -292,7 +295,7 @@ export default function MessagesPage() {
|
||||
onValueChange={(v) => {
|
||||
setRecipientType(v as RecipientType)
|
||||
setSelectedRole('')
|
||||
setRoundId('')
|
||||
setStageId('')
|
||||
setSelectedProgramId('')
|
||||
setSelectedUserId('')
|
||||
}}
|
||||
@@ -329,15 +332,15 @@ export default function MessagesPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{recipientType === 'ROUND_JURY' && (
|
||||
{recipientType === 'STAGE_JURY' && (
|
||||
<div className="space-y-2">
|
||||
<Label>Select Round</Label>
|
||||
<Select value={roundId} onValueChange={setRoundId}>
|
||||
<Label>Select Stage</Label>
|
||||
<Select value={stageId} onValueChange={setStageId}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Choose a round..." />
|
||||
<SelectValue placeholder="Choose a stage..." />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{(rounds as Array<{ id: string; name: string; program?: { name: string } }> | undefined)?.map((round) => (
|
||||
{rounds?.map((round) => (
|
||||
<SelectItem key={round.id} value={round.id}>
|
||||
{round.program ? `${round.program.name} - ${round.name}` : round.name}
|
||||
</SelectItem>
|
||||
|
||||
Reference in New Issue
Block a user