import React from "react";
import Link from "next/link";

import NotificationMessage from "../../Events/NotificationMessage";

export default class NotificationsList extends React.Component 
{
	constructor(props) 
	{
		super(props);
		this.state = {
		};
	}

	render() 
	{
		const { events } = this.props;
		let limit = 5;

		if (typeof window !== "undefined")
		{
			limit = window.innerWidth > 768 ? 5 : 3;
		}

		return (
			<>
				<ul className="list">
					{ events !== undefined && events !== null && events.slice(0, limit).map((event, index) => <NotificationMessage event={ event } key={ index } { ...this.props }/>) }
				</ul>
				<Link href="/events">
					<a className="all">Все события</a>
				</Link>
			</>
		)
	}
}