feat(plan): resolveCell/resolveGrid return arrays; dashboard shows up to 3
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,26 +44,27 @@ export default async function dashboardRoutes(
|
||||
}
|
||||
|
||||
// Today's work plan (personal) — powers the "Vaše dnešní zařazení" card.
|
||||
// resolveCell applies override-beats-range precedence; null = the user has
|
||||
// plan access but nothing is scheduled today. The category key is enriched
|
||||
// with its label + colour so the widget needs no extra query. todayStr uses
|
||||
// local (Europe/Prague) calendar date — the plan's @db.Date day.
|
||||
// resolveCell returns 0–3 records (override-beats-range layering); an empty
|
||||
// array means the user has plan access but nothing is scheduled today. Each
|
||||
// record's category key is enriched with its label + colour so the widget
|
||||
// needs no extra query. todayStr uses local (Europe/Prague) calendar date —
|
||||
// the plan's @db.Date day.
|
||||
if (has("attendance.record") || has("attendance.manage")) {
|
||||
const todayStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
|
||||
const cell = await resolveCell(userId, todayStr);
|
||||
if (cell) {
|
||||
const cat = await prisma.plan_categories.findUnique({
|
||||
where: { key: cell.category },
|
||||
select: { label: true, color: true },
|
||||
});
|
||||
result.today_plan = {
|
||||
...cell,
|
||||
category_label: cat?.label ?? cell.category,
|
||||
category_color: cat?.color ?? null,
|
||||
};
|
||||
} else {
|
||||
result.today_plan = null;
|
||||
}
|
||||
const cells = await resolveCell(userId, todayStr);
|
||||
result.today_plan = await Promise.all(
|
||||
cells.map(async (cell) => {
|
||||
const cat = await prisma.plan_categories.findUnique({
|
||||
where: { key: cell.category },
|
||||
select: { label: true, color: true },
|
||||
});
|
||||
return {
|
||||
...cell,
|
||||
category_label: cat?.label ?? cell.category,
|
||||
category_color: cat?.color ?? null,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Attendance admin — only for attendance.manage
|
||||
|
||||
Reference in New Issue
Block a user