import * as React from "react";
import * as moment from "moment";
import { IOrderVM } from "../../../../../apiModels/ViewModels";

type OrderListItemProps = {
	onOrderItemClick(orderItemId: number): void,
	orderListItem: IOrderVM
}

export default function OrderListItem({ onOrderItemClick, orderListItem }: OrderListItemProps) {
	const date = moment(orderListItem.orderedDate).format("DD.MM.YYYY HH:MM");
	
	return (
		<React.Fragment>
			<tr onClick={() => onOrderItemClick(orderListItem.id)}>
				<td className="order__list__item">{orderListItem.id}</td>
				<td className="order__list__price">{orderListItem.totalPrice} Kč</td>
				<td>{orderListItem.orderState}</td>
				<td>{orderListItem.paymentType}</td>
				<td>{orderListItem.orderItemsCount}</td>
				<td>{date}</td>
			</tr>
		</React.Fragment>
	);
}
