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 b531452..5255a9d 100644 --- a/angular/src/app/components/product-modal/product-modal.component.ts +++ b/angular/src/app/components/product-modal/product-modal.component.ts @@ -108,6 +108,7 @@ export class ProductModalComponent implements OnInit { return } } + this.cartService.changeTerminal(this.config.data.selectedTerminal) this.cartService.addToCart(this.cartProduct); this.dialogRef.close(); } diff --git a/angular/src/app/components/user-data-order/user-data-order.component.ts b/angular/src/app/components/user-data-order/user-data-order.component.ts index 63ff7de..9527530 100644 --- a/angular/src/app/components/user-data-order/user-data-order.component.ts +++ b/angular/src/app/components/user-data-order/user-data-order.component.ts @@ -28,6 +28,7 @@ import { GetTerminalsService } from 'src/app/services/get-terminals.service'; export class UserDataOrderComponent implements OnInit, OnDestroy { @Output() orderSubmitted = new EventEmitter(); + @Output() userNotFound = new EventEmitter(); readonly cities = environment.cities; public paymentMethods!: PaymentMethod[]; public loading = false; @@ -229,6 +230,9 @@ export class UserDataOrderComponent implements OnInit, OnDestroy { private async _createUserDataForm(): Promise { this.order = await this.orderService.getOrder(true); + if (this.order.userData?.errorCode === "Customer_CustomerNotFound") { + this.userNotFound.emit(null) + } this.userData = Object.assign({}, this.userData, this.order.userData); this.userData.city = this.cities[0]; this.userData.phone = this.order.phone; diff --git a/angular/src/app/interface/data.ts b/angular/src/app/interface/data.ts index e9d9443..c1cebc5 100644 --- a/angular/src/app/interface/data.ts +++ b/angular/src/app/interface/data.ts @@ -252,7 +252,8 @@ export interface UserData { city: string; phone: string | null; selectedTerminal: ITerminal | null; - name: string + name: string; + errorCode?: string; } export interface ITerminal { diff --git a/angular/src/app/models/order.ts b/angular/src/app/models/order.ts index 836a5a4..bf83a27 100644 --- a/angular/src/app/models/order.ts +++ b/angular/src/app/models/order.ts @@ -6,7 +6,7 @@ import { environment } from "src/environments/environment"; export interface OrderInfo { products: OrderProduct[]; - userData?: UserData; + userData: UserData | null; deliveryData?: DeliveryData; phone: string; token: string | undefined; @@ -16,7 +16,7 @@ export interface OrderInfo { export class Order { public products: OrderProduct[]; - public userData?: UserData; + public userData!: UserData | null; public deliveryData?: DeliveryData; public phone: string; public token: string | undefined; diff --git a/angular/src/app/pages/account/bonus-program/bonus-program.component.html b/angular/src/app/pages/account/bonus-program/bonus-program.component.html index e6c7661..e0077c9 100644 --- a/angular/src/app/pages/account/bonus-program/bonus-program.component.html +++ b/angular/src/app/pages/account/bonus-program/bonus-program.component.html @@ -15,6 +15,9 @@
+
+ Пользователь не найден, обратитесь к руководству +
Имя {{ diff --git a/angular/src/app/pages/account/bonus-program/bonus-program.component.ts b/angular/src/app/pages/account/bonus-program/bonus-program.component.ts index 95f5517..6d54954 100644 --- a/angular/src/app/pages/account/bonus-program/bonus-program.component.ts +++ b/angular/src/app/pages/account/bonus-program/bonus-program.component.ts @@ -11,6 +11,7 @@ import { CookiesService } from 'src/app/services/cookies.service'; import { DOCUMENT } from '@angular/common'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { WpJsonService } from 'src/app/services/wp-json.service'; +import { MatSnackBar } from '@angular/material/snack-bar'; @Component({ selector: 'app-bonus-program', @@ -36,6 +37,7 @@ export class BonusProgramComponent implements OnInit { @Inject(DOCUMENT) private document: Document, private http: HttpClient, private wpJsonService: WpJsonService, + private _snackBar: MatSnackBar ) { } @@ -55,6 +57,11 @@ export class BonusProgramComponent implements OnInit { this.loadingBonuses = true; this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({ next: (res) => { + if (res.customer_info.errorCode === 'Customer_CustomerNotFound') { + // this._snackBar.open('Пользователь не найден в системе! Обратитесь к руководству', 'Ок') + this.loadingBonuses = false; + return + } this.userName = res.customer_info.name this.accountData = { CardNumber: res.customer_info.cards[0]?.Number || '', diff --git a/angular/src/app/pages/account/orders/orders.component.ts b/angular/src/app/pages/account/orders/orders.component.ts index 9dd8baf..ccd8e18 100644 --- a/angular/src/app/pages/account/orders/orders.component.ts +++ b/angular/src/app/pages/account/orders/orders.component.ts @@ -46,6 +46,10 @@ export class OrdersComponent implements OnInit { const customerInfo = (await lastValueFrom( this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy) )) + if (customerInfo.customer_info.errorCode === 'Customer_CustomerNotFound') { + this.ordersLoadingStatus = false; + return + } const purchases: Purchase[] = (await lastValueFrom( this.wpJsonService.getTransactions(environment.systemId, token, environment.icardProxy, 30) ))[customerInfo.customer_info.id]; diff --git a/angular/src/app/pages/cart/cart.component.html b/angular/src/app/pages/cart/cart.component.html index 91b689b..e4567f6 100644 --- a/angular/src/app/pages/cart/cart.component.html +++ b/angular/src/app/pages/cart/cart.component.html @@ -154,47 +154,12 @@
- - -
-
- -

{{ message.summary }}

-

{{ message.detail }}

-
-
-
- -
-
- -
-
-
-
-
diff --git a/angular/src/app/pages/cart/cart.component.ts b/angular/src/app/pages/cart/cart.component.ts index 1be7bdb..3965755 100644 --- a/angular/src/app/pages/cart/cart.component.ts +++ b/angular/src/app/pages/cart/cart.component.ts @@ -72,10 +72,19 @@ export class CartComponent implements OnInit { async loadCart(): Promise { this.loading = true; this.order = await this.orderService.getOrder(true); + if (this.order?.userData?.errorCode === 'Customer_CustomerNotFound') { + this.userNotFound() + return + } if (this.order) this.price = this.order.price; this.loading = false; } + userNotFound(event: null = null) { + this.visibleSidebar = false + this._snackBar.open('Пользователь не найден в системе! Обратитесь к руководству', 'Ок') + } + removeFromCart(event: Event, guid: string): void { event.preventDefault(); this.orderService.removeFromCart(guid); @@ -125,17 +134,5 @@ export class CartComponent implements OnInit { this.visibleSidebar = false; } }); - // this.messageService.add({ key: 'c', sticky: true, severity: 'warn', summary: 'Вы уверены, что хотите очистить корзину?' }); - } - - onReject() { - this.messageService.clear('c'); - } - - onConfirm() { - this.cartService.clearCart(); - this.loadCart(); - this.visibleSidebar = false; - this.messageService.clear('c'); } } diff --git a/angular/src/app/pages/products/products.component.html b/angular/src/app/pages/products/products.component.html index b8a9849..d263551 100644 --- a/angular/src/app/pages/products/products.component.html +++ b/angular/src/app/pages/products/products.component.html @@ -44,7 +44,7 @@
{ const terminal = - JSON.parse(this.cookiesService.getItem('selectedTerminal') || 'null') || - this.cartService.selectedTerminal$; + JSON.parse(this.cookiesService.getItem('selectedTerminal') || 'null'); + const products: OrderProduct[] = []; + if (!terminal) { + return products + } const allData = await lastValueFrom( this.wpJsonService.getAllData(`${terminal.label}${terminal.id}`) ); - const products: OrderProduct[] = []; for (let i = 0; i < cart.products.length; i++) { const productSub = allData.products.find( (product: any) => product.id === cart.products[i].id