Files
AthenaFE/components/features/logs/DesktopLogsTable.tsx
T
2026-05-19 18:46:16 +02:00

71 lines
2.2 KiB
TypeScript

import { DataTable, Text } from "react-native-paper";
import { View } from "react-native";
import { UserLoginLog } from "@/store/api/usersApi";
import { formatDate, formatTimeWithSeconds } from "@/utils/dateUtils";
import { LogsTableHeader } from "@/components/features/logs/LogsTableHeader";
import { TableSortDirection } from "@/constants/tableSortDirectionEnum";
import { reasonLabel } from "@/utils/loginUtils";
interface DesktopLogsTableProps {
logs: UserLoginLog[];
sortColumn: string | null;
sortDirection: TableSortDirection;
onSort: (column: string) => void;
}
export const DesktopLogsTable = ({
logs,
sortColumn,
sortDirection,
onSort,
}: DesktopLogsTableProps) => {
return (
<DataTable>
<LogsTableHeader
sortColumn={sortColumn}
sortDirection={sortDirection}
onSort={onSort}
/>
{logs.map((log) => (
<DataTable.Row key={log.id}>
<DataTable.Cell>
<View className="flex-row items-center shrink pr-2">
<Text numberOfLines={1}>{log.name}</Text>
</View>
</DataTable.Cell>
<DataTable.Cell>
<View className="flex-row items-center shrink pr-2">
<Text numberOfLines={1}>{log.email}</Text>
</View>
</DataTable.Cell>
<DataTable.Cell>
<View className="flex-row items-center shrink pr-2">
<Text numberOfLines={1}>
{formatDate(log.lastLoginAt)}{" "}
{formatTimeWithSeconds(log.lastLoginAt)}
</Text>
</View>
</DataTable.Cell>
<DataTable.Cell>
<View className="flex-row items-center shrink pr-2">
<Text
numberOfLines={1}
style={{
color: log.status === "FAILURE" ? "#F83434" : "#22C927",
}}
>
{log.activity}
{log.status === "FAILURE" && reasonLabel(log.failureReason)
? ` - ${reasonLabel(log.failureReason)}`
: ""}
</Text>
</View>
</DataTable.Cell>
</DataTable.Row>
))}
</DataTable>
);
};