"use client"; import { signIn } from "next-auth/react"; import { useState } from "react"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { getRecentImpersonations, type RecentImpersonation } from "@calcom/lib/recentImpersonations"; import { Button } from "@calcom/ui/components/button"; import { PanelCard } from "@calcom/ui/components/card"; import { TableNew, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@calcom/ui/components/table"; interface RecentImpersonationsListProps { onImpersonate?: (username: string) => void; } export default function RecentImpersonationsList({ onImpersonate }: RecentImpersonationsListProps) { const { t } = useLocale(); const [recentImpersonations] = useState(() => getRecentImpersonations()); const handleQuickImpersonate = (username: string) => { if (onImpersonate) { onImpersonate(username); } else { signIn("impersonation-auth", { username: username.toLowerCase(), callbackUrl: `${WEBAPP_URL}/event-types`, }); } }; if (recentImpersonations.length === 0) { return null; } return (
User Impersonated At Actions {recentImpersonations.map((impersonation) => ( {impersonation.username} {new Date(impersonation.timestamp).toLocaleDateString()}{" "} {new Date(impersonation.timestamp).toLocaleTimeString()} ))}
); }