import { Component, Prop, State, Event, Watch, Element, EventEmitter, h, Fragment } from '@stencil/core'; import { Product } from '../../../classes/product'; import { formatCurrency, getConfig, resolveAsset } from '../../../classes/helpers'; @Component({ tag: 'progress-basket', styleUrl: 'progress-basket.css', scoped: true, }) export class ProgressBasket { @Prop() products!: Product[]; @Prop() total!: number; @Prop() frequency!: number; @Event() progressStepChanged: EventEmitter; @State() validOrder: boolean = true; @Element() el: HTMLInputElement; @Watch('total') checkValidOrder() { this.validOrder = this.total >= getConfig().minTotal; } getRemainingSpend() { return formatCurrency(getConfig().minTotal - this.total); } getProducts() { if (this.products.length == 0) { return (
No products added -
); } return ( {this.products.map(p => (
))}
); } getFrequency() { var button; if (this.validOrder) { button = ( ); } return (
Every {this.frequency} weeks {button}
); } render() { var proceed: any[]; if (!this.validOrder) { proceed = [
Spend {this.getRemainingSpend()} more to continue
, ]; } const cards = ['visa', 'mastercard', 'amex', 'paypal', 'klarna', 'apple-pay', 'google-pay']; this.el.style.setProperty('--background-img', 'url(' + resolveAsset('/assets/payment-bg.jpg') + ')'); return (
this.progressStepChanged.emit('frequency')}> < Back
Your basket
{this.getProducts()}
Total
{formatCurrency(this.total)}
{this.getFrequency()}
FREE UK Mainland Delivery
If you have a discount code you can apply it after clicking Secure Checkout.
{proceed}
{cards.map(card => (
{card.replace('-',
))}
); } }