Compare commits
No commits in common. "1be7dc2858d1635240ab4865e4e335fb62bd1ac2" and "3e30fae173b09cb11303fa350401d9530b8c5bc4" have entirely different histories.
1be7dc2858
...
3e30fae173
Binary file not shown.
@ -34,33 +34,7 @@ export async function GET(req: NextRequest) {
|
|||||||
? await getAttendanceByGym(targetGymId)
|
? await getAttendanceByGym(targetGymId)
|
||||||
: await db.getAllAttendance();
|
: await db.getAllAttendance();
|
||||||
|
|
||||||
// Get all users to enrich attendance with user names
|
return successResponse({ records: attendance });
|
||||||
const allUsers = await db.getAllUsers();
|
|
||||||
const userMap = new Map(
|
|
||||||
allUsers.map((u) => [
|
|
||||||
u.id,
|
|
||||||
{
|
|
||||||
firstName: u.firstName,
|
|
||||||
lastName: u.lastName,
|
|
||||||
email: u.email,
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enrich attendance records with user information
|
|
||||||
const enrichedAttendance = attendance.map((record) => {
|
|
||||||
const userInfo = userMap.get(record.userId);
|
|
||||||
return {
|
|
||||||
...record,
|
|
||||||
userName: userInfo
|
|
||||||
? `${userInfo.firstName} ${userInfo.lastName}`.trim() ||
|
|
||||||
userInfo.email
|
|
||||||
: record.userId,
|
|
||||||
userEmail: userInfo?.email,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return successResponse({ records: enrichedAttendance });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Admin attendance error:", error);
|
console.error("Admin attendance error:", error);
|
||||||
return new NextResponse("Internal Server Error", { status: 500 });
|
return new NextResponse("Internal Server Error", { status: 500 });
|
||||||
|
|||||||
@ -63,7 +63,7 @@ export default function AttendancePage() {
|
|||||||
className="border-b border-border/50 hover:bg-muted/50 transition-colors"
|
className="border-b border-border/50 hover:bg-muted/50 transition-colors"
|
||||||
>
|
>
|
||||||
<td className="py-3 px-4 text-sm">
|
<td className="py-3 px-4 text-sm">
|
||||||
{record.userName || record.userId.substring(0, 8) + "..."}
|
{record.userId.substring(0, 8)}...
|
||||||
</td>
|
</td>
|
||||||
<td className="py-3 px-4 text-sm capitalize text-muted-foreground">
|
<td className="py-3 px-4 text-sm capitalize text-muted-foreground">
|
||||||
{record.type}
|
{record.type}
|
||||||
|
|||||||
@ -55,8 +55,6 @@ export interface Gym {
|
|||||||
export interface AttendanceRecord {
|
export interface AttendanceRecord {
|
||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
userName?: string;
|
|
||||||
userEmail?: string;
|
|
||||||
checkInTime: Date;
|
checkInTime: Date;
|
||||||
checkOutTime?: Date;
|
checkOutTime?: Date;
|
||||||
date: string;
|
date: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user