currently check in implemented
This commit is contained in:
parent
db0d2cf215
commit
0011c9d4e5
Binary file not shown.
@ -19,7 +19,25 @@ export async function GET(request: NextRequest) {
|
||||
users.map(async (user) => {
|
||||
const { password: _, ...userWithoutPassword } = user;
|
||||
const client = await db.getClientByUserId(user.id);
|
||||
return { ...userWithoutPassword, client };
|
||||
|
||||
// Get active check-in status
|
||||
let isCheckedIn = false;
|
||||
let checkInTime = null;
|
||||
|
||||
if (client) {
|
||||
const activeCheckIn = await db.getActiveCheckIn(client.id);
|
||||
if (activeCheckIn) {
|
||||
isCheckedIn = true;
|
||||
checkInTime = activeCheckIn.checkInTime;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...userWithoutPassword,
|
||||
client,
|
||||
isCheckedIn,
|
||||
checkInTime
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@ -9,6 +9,20 @@ import { formatDate } from "@/lib/utils";
|
||||
|
||||
ModuleRegistry.registerModules([AllCommunityModule]);
|
||||
|
||||
function getTimeAgo(date: Date): string {
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - date.getTime();
|
||||
const diffMins = Math.floor(diffMs / 60000);
|
||||
const diffHours = Math.floor(diffMins / 60);
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
|
||||
if (diffMins < 1) return 'just now';
|
||||
if (diffMins < 60) return `${diffMins}m ago`;
|
||||
if (diffHours < 24) return `${diffHours}h ago`;
|
||||
return `${diffDays}d ago`;
|
||||
}
|
||||
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
@ -17,6 +31,8 @@ interface User {
|
||||
role: string;
|
||||
phone?: string;
|
||||
createdAt: Date;
|
||||
isCheckedIn?: boolean;
|
||||
checkInTime?: Date;
|
||||
client?: {
|
||||
id: string;
|
||||
membershipType: string;
|
||||
@ -152,6 +168,27 @@ export function UserGrid({
|
||||
},
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
headerName: "Currently Checked In",
|
||||
valueGetter: (params) => params.data?.isCheckedIn,
|
||||
filter: "agTextColumnFilter",
|
||||
sortable: true,
|
||||
cellRenderer: (params: any) => {
|
||||
if (!params.data?.isCheckedIn) {
|
||||
return <span className="text-gray-400">—</span>;
|
||||
}
|
||||
|
||||
const checkInTime = params.data.checkInTime ? new Date(params.data.checkInTime) : null;
|
||||
const timeAgo = checkInTime ? getTimeAgo(checkInTime) : '';
|
||||
|
||||
return (
|
||||
<span className="px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 border border-green-200">
|
||||
✓ Checked In {timeAgo && `(${timeAgo})`}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
headerName: "Join Date",
|
||||
valueGetter: (params) =>
|
||||
|
||||
@ -13,6 +13,8 @@ interface User {
|
||||
role: string;
|
||||
phone?: string;
|
||||
createdAt: Date;
|
||||
isCheckedIn?: boolean;
|
||||
checkInTime?: Date;
|
||||
client?: {
|
||||
id: string;
|
||||
membershipType: string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user