diff --git a/angular/src/app/components/product-modal/product-modal.component.html b/angular/src/app/components/product-modal/product-modal.component.html
index 10ae47b..70fc19c 100644
--- a/angular/src/app/components/product-modal/product-modal.component.html
+++ b/angular/src/app/components/product-modal/product-modal.component.html
@@ -55,3 +55,40 @@
+
+
+
+
+
+
+
{{ message.summary }}
+
{{ message.detail }}
+
+
+
+
+
diff --git a/angular/src/app/components/product-modal/product-modal.component.ts b/angular/src/app/components/product-modal/product-modal.component.ts
index 5255a9d..f9eed5a 100644
--- a/angular/src/app/components/product-modal/product-modal.component.ts
+++ b/angular/src/app/components/product-modal/product-modal.component.ts
@@ -6,6 +6,7 @@ import { CartProduct } from 'src/app/models/cart-product';
import { CartService } from 'src/app/services/cart.service';
import { WpJsonService } from 'src/app/services/wp-json.service';
import { ChangeValue } from '../change-quantity/change-quantity.component';
+import { CookiesService } from 'src/app/services/cookies.service';
@Component({
selector: 'app-product-modal',
@@ -18,7 +19,8 @@ export class ProductModalComponent implements OnInit {
public modifiersGroups!: ModifiersGroup[];
public modifiers!: Modifier[];
public cartProduct!: CartProduct;
- public isValidate: boolean = false
+ public isValidate: boolean = false;
+ private selectedTerminal: any;
constructor(
public dialogRef: DynamicDialogRef,
@@ -26,12 +28,14 @@ export class ProductModalComponent implements OnInit {
private wpJsonService: WpJsonService,
private cartService: CartService,
private messageService: MessageService,
+ private cookiesService: CookiesService
) { }
ngOnInit(): void {
this.product = this.config.data.product
this.modifiersGroups = this.config.data.modifiersGroups
this.modifiers = this.config.data.modifiers
+ this.selectedTerminal = this.config.data.selectedTerminal
this.cartProduct = new CartProduct(this.product.id, this.product.name, this.modifiersFilter(), this.modifiers, this.product.price);
}
@@ -93,10 +97,24 @@ export class ProductModalComponent implements OnInit {
}
+ onReject() {
+ this.messageService.clear('cC');
+ }
+
+ onConfirm() {
+ this.cartService.clearCart()
+ this.cartService.changeTerminal(this.config.data.selectedTerminal)
+ this.cartService.addToCart(this.cartProduct);
+ this.messageService.clear('cC');
+ this.dialogRef.close();
+ }
+
addToCart(event: Event) {
if (event) {
event.preventDefault()
}
+ const cookiesTerminal = JSON.parse(this.cookiesService.getItem('selectedTerminal') || '')
+
for (let modifiersGroup of this.cartProduct.modifiers) {
const isValidModifier = modifiersGroup.allQuantity < modifiersGroup.restrictions.minQuantity
if (isValidModifier) {
@@ -108,6 +126,10 @@ export class ProductModalComponent implements OnInit {
return
}
}
+ if (this.selectedTerminal.id !== cookiesTerminal?.id) {
+ this.messageService.add({ key: 'cC', sticky: true, severity: 'warn', summary: 'В заказе могут быть товары только из одного магазина, очистить корзину для создания нового заказа?' });
+ return
+ }
this.cartService.changeTerminal(this.config.data.selectedTerminal)
this.cartService.addToCart(this.cartProduct);
this.dialogRef.close();
diff --git a/angular/src/app/pages/account/account.component.html b/angular/src/app/pages/account/account.component.html
index d46f1c2..424be70 100644
--- a/angular/src/app/pages/account/account.component.html
+++ b/angular/src/app/pages/account/account.component.html
@@ -4,7 +4,7 @@
'auth-page': showAuthoriztion
}"
>
-
+
-