import { CardModel } from './card.model'; import { IconModel } from '../icon/icon.model'; import { ButtonModel } from '../button/button.model'; import { LayoutModel } from '../layout.model'; /** * Class representing the product card */ export class ProductCardModel extends CardModel { /** *

The name of the product.

*/ name: string; /** *

It is the price of the product.

*/ price: string; /** *

The amount of the item in the stocks.

*/ amount: number; /** *

It represents the buy action button for the product.

*/ buy: ButtonModel; /** *

It represents the add to Cart action button for a product.

*/ addToCart: ButtonModel; /** *

Function to be called when the user press Buy.

*/ onBuy: any; /** *

Function to be called when the user press Add to Cart.

*/ onAdd: any; /** * It is the constructor for the card component. It takes the required string values to create the card object */ constructor(values: Object = {}) { super(); this.layout= { type:"product", }; Object.assign(this, values); let iconAdd = new IconModel ({ name: "add_shopping_cart", type: "mi", size: "25px", color: { foreground: "lightblue", background: "transparent" } }); this.addToCart = new ButtonModel( { color: { foreground: "white", background: "accent" }, icon: iconAdd, iconPosition:"right", menu: null }); let iconBuy= new IconModel ({ name: "shopping_basket", type: "mi", size: "20px", color: { foreground: "white", background: "transparent" } }); this.buy = new ButtonModel( { label:"Buy", color: { foreground: "white", background: "primary" }, icon: iconBuy, iconPosition: "right", menu: null }); } }