import * as React from 'react' import { RouteComponentProps } from "react-router"; import { Product } from './types'; import { Quantity } from './ProductsComponent'; import { Map } from 'immutable' export type CartComponentState = { } // TODO 9: complete the implementation of the type below (1.5 pt) export type CartComponentProps = { update_user: (data: string) => void, user: string, cart: Map, update_cart: (cart: Map) => void, submit: () => void } export class CartComponent extends React.Component { constructor(props: CartComponentProps) { super(props) this.state = {} } public render() { return
this.props.update_user(e.target.value)} value={this.props.user} required />

{/* TODO 10: complete the implementation of the type below (1.5 pt) NOTE: you should be able to remove an item from the cart (or decrease the amount). (hint button) */} { this.props.cart.count() == 0 ? "Your cart is empty." :
{ this.props.cart.map((q, p) => { return
{p.Name} x {q}
}).valueSeq() }
-------------

Total: {this.props.cart.map((q, p) => q * p.Price).reduce((a, b) => a + b, 0)}

}
{(() => { const regex = RegExp('[a-zA-Z]+@[a-zA-Z]+'); let is_email = regex.test(this.props.user) return })()}
} }