import React from 'react'; import { UserIcon } from '@heroicons/react/outline'; import { Link } from 'react-router-dom'; import Tooltip from '@/components/elements/tooltip/Tooltip'; import Translate from '@/components/elements/Translate'; import { format, formatDistanceToNowStrict } from 'date-fns'; import { ActivityLog } from '@definitions/user'; import { useLocation } from 'react-router'; import ActivityLogMetaButton from '@/components/elements/activity/ActivityLogMetaButton'; import { TerminalIcon } from '@heroicons/react/solid'; import classNames from 'classnames'; import style from './style.module.css'; interface Props { activity: ActivityLog; children?: React.ReactNode; } export default ({ activity, children }: Props) => { const location = useLocation(); const actor = activity.relationships.actor; const queryTo = (params: Record): string => { const current = new URLSearchParams(location.search); Object.keys(params).forEach(key => current.set(key, params[key])); return current.toString(); }; const properties = Object.keys(activity.properties).reduce((obj, key) => ({ ...obj, [key]: key === 'count' || key.endsWith('_count') ? activity.properties[key] : `${activity.properties[key]}`, }), {}); return (
{actor ? {'User : }
{actor?.username || 'System'}  —  {activity.event}
{activity.isApi && } {children}

{activity.ip}  |  {formatDistanceToNowStrict(activity.timestamp, { addSuffix: true })}
{activity.hasAdditionalMetadata && }
); };