import React from "react";
import ItemGroup from "../ItemGroup";
import UserItem from "./UserItem";

const ItemLogUser = (props: IItemLogUserProps) => {
	const { items, getLog } = props;
	const { date, user: users } = items;

	const count = users.reduce((total: number, user: any) => total + user.logActivity.length, 0);

	return (
		<ItemGroup date={date} count={count}>
			{users.map((user: any) => (
				<UserItem key={user.id} user={user} getLog={getLog} />
			))}
		</ItemGroup>
	);
};

interface IItemLogUserProps {
	items: any;
	getLog(): void;
}

export default ItemLogUser;
