Admin platform audit: fix bugs, harden backend, add auto-refresh, clean dead code
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m23s
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m23s
Phase 1 — Critical bugs: - Fix deliberation participant selection (wire jury group query) - Fix reports "By Round" tab (inline content instead of 404 route) - Fix messages "Sent History" (add message.sent procedure, wire tab) - Add missing fields to competition award form (criteriaText, maxRankedPicks) - Wire LiveControlPanel buttons (cursor, voting, scores) - Fix ResultLockControls empty snapshot (fetch actual data before lock) - Fix SubmissionWindowManager losing fields on edit Phase 2 — Backend fixes: - Remove write-in-query from specialAward.get - Fix award eligibility job overwriting manual shortlist overrides - Fix filtering startJob deleting all prior results (defer cleanup to post-success) - Tighten access control: protectedProcedure → adminProcedure on 8 procedures - Add audit logging to deliberation mutations - Add FINALIST/SEMIFINALIST delete guard on project.delete/bulkDelete Phase 3 — Auto-refresh: - Add refetchInterval to 15+ admin pages/components (10s–30s) - Fix AI job polling: derive speed from job status for all viewers Phase 4 — Dead code cleanup: - Delete unused command-palette, pdf-report, admin-page-transition - Remove dead subItems sidebar code, unused GripVertical import - Replace redundant isGenerating state with mutation.isPending - Add Role column to jury members table - Remove misleading manual mentor assignment stub Phase 5 — UX improvements: - Fix rounds page single-competition assumption (add selector) - Remove raw UUID fallback in deliberation config - Fix programs page "Stage" → "Round" terminology Phase 6 — Backend hardening: - Complete logAudit calls (add prisma, ipAddress, userAgent) - Batch analytics queries (fix N+1 in getCrossRoundComparison, getYearOverYear) - Batch user.bulkCreate writes (assignments, jury memberships, intents) - Remove any casts from deliberation service (typed PrismaClient + TransactionClient) - Fix stale DeliberationStatus enum values blocking build 40 files changed, 1010 insertions(+), 612 deletions(-) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ export default function DeliberationListPage({
|
||||
const router = useRouter();
|
||||
const utils = trpc.useUtils();
|
||||
const [createDialogOpen, setCreateDialogOpen] = useState(false);
|
||||
const [selectedJuryGroupId, setSelectedJuryGroupId] = useState('');
|
||||
const [formData, setFormData] = useState({
|
||||
roundId: '',
|
||||
category: 'STARTUP' as 'STARTUP' | 'BUSINESS_CONCEPT',
|
||||
@@ -54,8 +55,17 @@ export default function DeliberationListPage({
|
||||
);
|
||||
const rounds = competition?.rounds || [];
|
||||
|
||||
// TODO: Add getJuryMembers endpoint if needed for participant selection
|
||||
const juryMembers: any[] = [];
|
||||
// Jury groups & members for participant selection
|
||||
const { data: juryGroups = [] } = trpc.juryGroup.list.useQuery(
|
||||
{ competitionId: params.competitionId },
|
||||
{ enabled: !!params.competitionId }
|
||||
);
|
||||
|
||||
const { data: selectedJuryGroup } = trpc.juryGroup.getById.useQuery(
|
||||
{ id: selectedJuryGroupId },
|
||||
{ enabled: !!selectedJuryGroupId }
|
||||
);
|
||||
const juryMembers = selectedJuryGroup?.members ?? [];
|
||||
|
||||
const createSessionMutation = trpc.deliberation.createSession.useMutation({
|
||||
onSuccess: (data) => {
|
||||
@@ -76,6 +86,10 @@ export default function DeliberationListPage({
|
||||
toast.error('Please select a round');
|
||||
return;
|
||||
}
|
||||
if (formData.participantUserIds.length === 0) {
|
||||
toast.error('Please select at least one participant');
|
||||
return;
|
||||
}
|
||||
|
||||
createSessionMutation.mutate({
|
||||
competitionId: params.competitionId,
|
||||
@@ -273,6 +287,78 @@ export default function DeliberationListPage({
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* Participant Selection */}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="juryGroup">Jury Group *</Label>
|
||||
<Select
|
||||
value={selectedJuryGroupId}
|
||||
onValueChange={(value) => {
|
||||
setSelectedJuryGroupId(value);
|
||||
setFormData({ ...formData, participantUserIds: [] });
|
||||
}}
|
||||
>
|
||||
<SelectTrigger id="juryGroup">
|
||||
<SelectValue placeholder="Select jury group" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{juryGroups.map((group: any) => (
|
||||
<SelectItem key={group.id} value={group.id}>
|
||||
{group.name} ({group._count?.members ?? 0} members)
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{juryMembers.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label>Participants ({formData.participantUserIds.length}/{juryMembers.length})</Label>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const allIds = juryMembers.map((m: any) => m.user.id);
|
||||
const allSelected = allIds.every((id: string) => formData.participantUserIds.includes(id));
|
||||
setFormData({
|
||||
...formData,
|
||||
participantUserIds: allSelected ? [] : allIds,
|
||||
});
|
||||
}}
|
||||
>
|
||||
{juryMembers.every((m: any) => formData.participantUserIds.includes(m.user.id))
|
||||
? 'Deselect All'
|
||||
: 'Select All'}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="max-h-48 space-y-2 overflow-y-auto rounded-md border p-3">
|
||||
{juryMembers.map((member: any) => (
|
||||
<div key={member.id} className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id={`member-${member.user.id}`}
|
||||
checked={formData.participantUserIds.includes(member.user.id)}
|
||||
onCheckedChange={(checked) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
participantUserIds: checked
|
||||
? [...formData.participantUserIds, member.user.id]
|
||||
: formData.participantUserIds.filter((id: string) => id !== member.user.id),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<Label htmlFor={`member-${member.user.id}`} className="flex-1 font-normal">
|
||||
{member.user.name || member.user.email}
|
||||
<span className="ml-2 text-xs text-muted-foreground">
|
||||
{member.role === 'CHAIR' ? 'Chair' : member.role === 'OBSERVER' ? 'Observer' : 'Member'}
|
||||
</span>
|
||||
</Label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
|
||||
Reference in New Issue
Block a user