Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92252382ac | ||
|
|
8bed920de1 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "2.0.7",
|
"version": "2.0.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/server.js",
|
"main": "dist/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export const STATUS_LABELS: Record<string, string> = {
|
|||||||
away: "Přestávka",
|
away: "Přestávka",
|
||||||
out: "Nepřihlášen",
|
out: "Nepřihlášen",
|
||||||
leave: "Nepřítomen",
|
leave: "Nepřítomen",
|
||||||
|
absent: "Nepřítomen",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Re-exported from the single source of truth so the dashboard activity feed
|
// Re-exported from the single source of truth so the dashboard activity feed
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default async function dashboardRoutes(
|
|||||||
|
|
||||||
// Attendance admin — only for attendance.manage
|
// Attendance admin — only for attendance.manage
|
||||||
if (has("attendance.manage")) {
|
if (has("attendance.manage")) {
|
||||||
const [todayAttendance, onLeaveToday, usersCount] = await Promise.all([
|
const [todayAttendance, onLeaveToday, activeUsers] = await Promise.all([
|
||||||
prisma.attendance.findMany({
|
prisma.attendance.findMany({
|
||||||
where: {
|
where: {
|
||||||
shift_date: { gte: todayStart, lt: todayEnd },
|
shift_date: { gte: todayStart, lt: todayEnd },
|
||||||
@@ -89,8 +89,13 @@ export default async function dashboardRoutes(
|
|||||||
users: { select: { id: true, first_name: true, last_name: true } },
|
users: { select: { id: true, first_name: true, last_name: true } },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
prisma.users.count({ where: { is_active: true } }),
|
prisma.users.findMany({
|
||||||
|
where: { is_active: true },
|
||||||
|
select: { id: true, first_name: true, last_name: true },
|
||||||
|
orderBy: [{ last_name: "asc" }, { first_name: "asc" }],
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
const usersCount = activeUsers.length;
|
||||||
|
|
||||||
const userAttendanceMap = new Map<number, (typeof todayAttendance)[0]>();
|
const userAttendanceMap = new Map<number, (typeof todayAttendance)[0]>();
|
||||||
for (const a of todayAttendance) {
|
for (const a of todayAttendance) {
|
||||||
@@ -153,6 +158,25 @@ export default async function dashboardRoutes(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show every active employee — those with no attendance record today
|
||||||
|
// appear as "absent" so the card reflects the whole team, not just those
|
||||||
|
// who clocked in or are on leave.
|
||||||
|
const recordedUserIds = new Set<number>([
|
||||||
|
...userAttendanceMap.keys(),
|
||||||
|
...leaveUserIds,
|
||||||
|
]);
|
||||||
|
for (const user of activeUsers) {
|
||||||
|
if (recordedUserIds.has(user.id)) continue;
|
||||||
|
attendanceUsers.push({
|
||||||
|
user_id: user.id,
|
||||||
|
name: `${user.first_name} ${user.last_name}`,
|
||||||
|
initials:
|
||||||
|
`${user.first_name?.charAt(0) ?? ""}${user.last_name?.charAt(0) ?? ""}`.toUpperCase(),
|
||||||
|
status: "absent",
|
||||||
|
arrived_at: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
result.attendance = {
|
result.attendance = {
|
||||||
present_today: presentCount,
|
present_today: presentCount,
|
||||||
total_active: usersCount,
|
total_active: usersCount,
|
||||||
|
|||||||
Reference in New Issue
Block a user