Есть код, в котором данные о заказе отправляются на электронную почту. Код:
import { Component, OnInit } from '@angular/core';
import { ProductService } from '../shared/product.service';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { OrderService } from '../shared/order.service';
import emailjs, { EmailJSResponseStatus } from 'emailjs-com';
@Component({
selector: 'app-cart-page',
templateUrl: './cart-page.component.html',
styleUrls: ['./cart-page.component.scss']
})
export class CartPageComponent implements OnInit {
cartProducts = []
totalPrice = 0
added = ''
form : FormGroup
submitted = false
constructor(
private productServ : ProductService,
private orderServ : OrderService
) { }
ngOnInit() {
this.cartProducts = this.productServ.cartProducts
for (let i = 0; i < this.cartProducts.length; i++) {
this.totalPrice += +this.cartProducts[i].price
}
this.form = new FormGroup({
name: new FormControl(null, Validators.required),
phone: new FormControl(null, Validators.required),
address: new FormControl(null, Validators.required),
payment: new FormControl('Cash'),
})
}
public sendEmail($event: Event) {
if (this.form.invalid) {
return
}
this.submitted = true
const order = {
name: this.form.value.name,
phone: this.form.value.phone,
address: this.form.value.address,
payment: this.form.value.payment,
orders: this.cartProducts,
price: this.totalPrice,
date: new Date()
}
emailjs.sendForm('service_lkw4wsl', 'template_rtee3qn', toString(order), 'user_4dZI6eHowyywWMEMQGidG')
this.orderServ.create(order).subscribe( res => {
this.added = 'Delivery is framed'
this.submitted = false
})
}
delete(product) {
this.totalPrice -= +product.price
this.cartProducts.splice(this.cartProducts.indexOf(product), 1)
}
}
Но при компиляции выдаёт ошибку:
ERROR in src/app/cart-page/cart-page.component.ts(56,70): error TS2554: Expected 0 arguments, but got 1.
Проект доступен на ГитХаб -
https://github.com/FastGameDev/Shop.git
Заранее спасибо!!!