dev #13306
исправил ошибку отсутствия номера телефона при заказе, поправил модель данных заказа, добавил автоматическую смену даты выдачи раз в минуту
This commit is contained in:
parent
e7a389b484
commit
1960c6a7d3
@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { DeliveryData, DeliveryType, PaymentMethod, UserData } from 'src/app/interface/data';
|
||||
import { paymentMethods } from "../../app.constants";
|
||||
@ -24,7 +24,7 @@ import { lastValueFrom } from 'rxjs';
|
||||
templateUrl: './user-data-order.component.html',
|
||||
styleUrls: ['./user-data-order.component.scss']
|
||||
})
|
||||
export class UserDataOrderComponent implements OnInit {
|
||||
export class UserDataOrderComponent implements OnInit, OnDestroy {
|
||||
|
||||
@Output() orderSubmitted = new EventEmitter<void>();
|
||||
readonly cities = environment.cities;
|
||||
@ -40,6 +40,7 @@ export class UserDataOrderComponent implements OnInit {
|
||||
public showMyMessage: boolean = false;
|
||||
public order!: Order;
|
||||
public showAuthoriztion = false;
|
||||
private intervalTimeDelivery!: any
|
||||
|
||||
public userData: UserData = {
|
||||
first_name: null,
|
||||
@ -87,6 +88,11 @@ export class UserDataOrderComponent implements OnInit {
|
||||
}
|
||||
})
|
||||
this.deliverData.deliveryDate = moment().add(this.checkoutConfig?.timeDelivery?.changeTime?.defaultValue || 0, 'minutes').toDate()
|
||||
this.intervalTimeDelivery = setInterval(() => {
|
||||
this.mainFormGroup.controls['deliveryDataForm'].patchValue({
|
||||
deliveryDate: moment().add(this.checkoutConfig?.timeDelivery?.changeTime?.defaultValue || 0, 'minutes').toDate()
|
||||
})
|
||||
}, 60_000)
|
||||
this.paymentMethods = this.checkoutConfig.payments.values
|
||||
this.deliverData.paymentMethod = this.paymentMethods[this.checkoutConfig.payments.default]
|
||||
|
||||
@ -115,6 +121,7 @@ export class UserDataOrderComponent implements OnInit {
|
||||
}
|
||||
|
||||
phoneConfirmed() {
|
||||
this._createMainForm();
|
||||
this.showAuthoriztion = false
|
||||
this.checkAuthorization(true)
|
||||
}
|
||||
@ -203,7 +210,7 @@ export class UserDataOrderComponent implements OnInit {
|
||||
this.loading = false;
|
||||
}
|
||||
catch (e) {
|
||||
console.error('Erroe: ', e);
|
||||
console.error('Error: ', e);
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
@ -241,5 +248,9 @@ export class UserDataOrderComponent implements OnInit {
|
||||
comment: [this.deliverData.comment, [Validators.maxLength(255),]]
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
clearInterval(this.intervalTimeDelivery)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ export class Order {
|
||||
paymentsystem: this.deliveryData?.paymentMethod?.type,
|
||||
phone: this.phone,
|
||||
persons: 1,
|
||||
name: "31",
|
||||
name: this.userData?.first_name,
|
||||
payment: {
|
||||
delivery_price: 100,
|
||||
products: this.products.map(product => {
|
||||
@ -54,7 +54,7 @@ export class Order {
|
||||
subtotal: this.price,
|
||||
delivery_comment: this.deliveryData?.comment,
|
||||
delivery: this.deliveryData?.deliveryType?.type,
|
||||
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? null : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`,
|
||||
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? '' : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`,
|
||||
amount: this.price + 100,
|
||||
terminal_id: this.terminal_id
|
||||
},
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
[fullScreen]="isFullScreen"
|
||||
[baseZIndex]="10000"
|
||||
position="right"
|
||||
(onHide)="hide()"
|
||||
>
|
||||
<div
|
||||
class="cart"
|
||||
|
||||
@ -45,6 +45,10 @@ export class CartComponent implements OnInit {
|
||||
this.loadCart()
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.orderConfirmed = false;
|
||||
}
|
||||
|
||||
changeDullScreenMode() {
|
||||
if (this.width < 650) {
|
||||
this.isFullScreen = true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user