feat(dashboard): add Recording Assignments section
- Extend dashboard API to include recordingSuggestions for each event - Add toBeRecorded and toRecord arrays with heat and user details - Export RecordingSummaryCard component - Add Recording Assignments section to DashboardPage - Filter and display events with recording suggestions - Show up to 2 suggestions per event with View Details link
This commit is contained in:
@@ -49,7 +49,7 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
// Socket may not be initialized (e.g., during tests)
|
||||
}
|
||||
|
||||
// Get user's heats for each event
|
||||
// Get user's heats and recording suggestions for each event
|
||||
const activeEvents = await Promise.all(
|
||||
eventParticipants.map(async (ep) => {
|
||||
const heats = await prisma.eventUserHeat.findMany({
|
||||
@@ -75,6 +75,47 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
},
|
||||
});
|
||||
|
||||
// Get recording suggestions for this event
|
||||
const heatIds = heats.map(h => h.id);
|
||||
|
||||
// Suggestions where user is the dancer (someone records them)
|
||||
const toBeRecorded = await prisma.recordingSuggestion.findMany({
|
||||
where: {
|
||||
eventId: ep.event.id,
|
||||
heatId: { in: heatIds },
|
||||
},
|
||||
include: {
|
||||
heat: {
|
||||
include: {
|
||||
division: { select: { abbreviation: true } },
|
||||
competitionType: { select: { abbreviation: true } },
|
||||
},
|
||||
},
|
||||
recorder: {
|
||||
select: { id: true, username: true, avatar: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Suggestions where user is the recorder (they record someone)
|
||||
const toRecord = await prisma.recordingSuggestion.findMany({
|
||||
where: {
|
||||
eventId: ep.event.id,
|
||||
recorderId: userId,
|
||||
},
|
||||
include: {
|
||||
heat: {
|
||||
include: {
|
||||
division: { select: { abbreviation: true } },
|
||||
competitionType: { select: { abbreviation: true } },
|
||||
user: {
|
||||
select: { id: true, username: true, avatar: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
id: ep.event.id,
|
||||
slug: ep.event.slug,
|
||||
@@ -91,6 +132,28 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
heatNumber: h.heatNumber,
|
||||
role: h.role,
|
||||
})),
|
||||
recordingSuggestions: {
|
||||
toBeRecorded: toBeRecorded.map(s => ({
|
||||
id: s.id,
|
||||
status: s.status,
|
||||
heat: {
|
||||
heatNumber: s.heat.heatNumber,
|
||||
division: s.heat.division?.abbreviation,
|
||||
competitionType: s.heat.competitionType?.abbreviation,
|
||||
},
|
||||
recorder: s.recorder,
|
||||
})),
|
||||
toRecord: toRecord.map(s => ({
|
||||
id: s.id,
|
||||
status: s.status,
|
||||
heat: {
|
||||
heatNumber: s.heat.heatNumber,
|
||||
division: s.heat.division?.abbreviation,
|
||||
competitionType: s.heat.competitionType?.abbreviation,
|
||||
},
|
||||
dancer: s.heat.user,
|
||||
})),
|
||||
},
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user