diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html index 3f958cf..370810c 100644 --- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html +++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.html @@ -1,19 +1,19 @@ - +
-

Уровень {{ authService.error ? '--' : authService.userInfo.current_level_and_cashback?.current_level }}

+

Уровень {{ authService.error ? '--' : authService.userInfo?.current_level_and_cashback?.current_level }}

Кэшбек {{ authService.error ? '--' : authService.currentLvlPeriod.percent }}%

- +

Отрицательный баланс бонусов, свяжитесь с техподдержкой

- +

- {{ authService.error ? '--' : Math.floor(authService.userInfo.walletBalances) }} + {{ authService.error ? '--' : Math.floor(authService.userInfo!.walletBalances) }} бонусов

@@ -32,40 +32,40 @@
Покажи бариста
+

+
+ > + + +
+ +

+ Упс, что-то пошло не так.. + Мы уже работаем над этой проблемой. + Попробуйте обновить страницу или зайти попозже. + Приносим извинения за неудобства. +

+
- - -

- Упс, что-то пошло не так.. - Мы уже работаем над этой проблемой. - Попробуйте обновить страницу или зайти попозже. - Приносим извинения за неудобства. -

-
- - -
- -
-

Данные недоступны, попробуйте позже

-
-
- + + + + +
diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.scss b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.scss index b479d5e..29d5bde 100644 --- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.scss +++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.scss @@ -208,6 +208,18 @@ justify-content: center; align-items: center; } + + .broken { + display: flex; + flex-direction: column; + align-items: center; + gap: 20px; + + p { + max-width: 80%; + text-align: center; + } + } } app-accordion { diff --git a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts index a745c53..51804f2 100644 --- a/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts +++ b/angular/src/app/presentation-options/default-option/pages/guest-card/guest-card.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { MatBottomSheet } from '@angular/material/bottom-sheet'; import { ExitComponent } from 'src/app/components/exit/exit.component'; import { CookiesService } from 'src/app/services/cookies.service'; @@ -115,7 +115,7 @@ export class GuestCardComponent implements OnInit { return format( template, - `${this.authService.userInfo?.next_level.sum_for_next_level}`, + `${this.authService.userInfo?.next_level.sum_for_next_level ?? '--'}`, `${this.authService.currentPeriod[1].locale('ru').format('D MMMM')}` ); } diff --git a/angular/src/app/services/auth.service.ts b/angular/src/app/services/auth.service.ts index 389418e..f3c7bb8 100644 --- a/angular/src/app/services/auth.service.ts +++ b/angular/src/app/services/auth.service.ts @@ -4,7 +4,12 @@ import { WpJsonService } from './wp-json.service'; import { environment } from 'src/environments/environment'; import { JsonrpcService, RpcService } from './jsonrpc.service'; import { MessageService } from 'primeng/api'; -import { UserInfo, lvlPeriod, UserInfoWalletBalance, Moment } from '../interface/data'; +import { + UserInfo, + lvlPeriod, + UserInfoWalletBalance, + Moment, +} from '../interface/data'; import { lvlPeriods } from 'src/app/app.constants'; import moment from 'moment-timezone'; import { Router } from '@angular/router'; @@ -22,7 +27,10 @@ export class AuthService { get currentLvlPeriod(): lvlPeriod { return lvlPeriods[ - this.userInfo?.current_level_and_cashback ? this.userInfo?.current_level_and_cashback.current_level - 1 : 0]; + this.userInfo?.current_level_and_cashback + ? this.userInfo?.current_level_and_cashback.current_level - 1 + : 0 + ]; } constructor( @@ -30,7 +38,7 @@ export class AuthService { private wpJsonService: WpJsonService, private jsonrpc: JsonrpcService, private messageService: MessageService, - private router: Router, + private router: Router ) { this.getCurrentQuarterOfYear(); } @@ -50,31 +58,25 @@ export class AuthService { return; } - this.error = null; + this.error = null; this.loading = true; this.wpJsonService - .getCustomerInfo( - environment.systemId, - token, - environment.icardProxy, - ) + .getCustomerInfo(environment.systemId, token, environment.icardProxy) .subscribe({ next: (value) => { + this.loading = false; this.userInfo = value.customer_info; if (value && value.error && value.error.code === 11) { - this.wpJsonService.newCustomer( - environment.systemId, - token, - environment.icardProxy, - ) + this.wpJsonService + .newCustomer(environment.systemId, token, environment.icardProxy) .subscribe({ next: () => { this.getUserInfo(); - } - }) + }, + }); } else if (value && value.error && value.error.code > 1) { - this.error = value.error; + this.error = value.error; this.messageService.clear(); this.messageService.add({ severity: 'error', @@ -86,10 +88,8 @@ export class AuthService { }, error: (e) => { this.error = e; - }, - complete: () => { this.loading = false; - } + }, }); } @@ -121,6 +121,7 @@ export class AuthService { ) .subscribe({ next: (result) => { + this.loading = false; if (result.code !== 0) { this.messageService.clear(); this.messageService.add({ @@ -141,8 +142,6 @@ export class AuthService { }, error: (error) => { console.error('Error: ', error); - }, - complete: () => { this.loading = false; }, }); @@ -161,29 +160,32 @@ export class AuthService { ) .subscribe({ next: (result) => { + this.loading = false; if (result.code === 0) { this.cookiesService.setCookie('token', result?.data?.token); - this.jsonrpc.rpc( - { - method: 'updateAdditionalInfo', - params: [ - { - first_name: name, - birth_day: '01.01.1999' - }, - ], - }, - RpcService.authService, - true - ).subscribe({ - next: () => { - this.router.navigate(['/']); - this.getUserInfo(); - }, - error: (err) => { - console.error(err); - }, - }) + this.jsonrpc + .rpc( + { + method: 'updateAdditionalInfo', + params: [ + { + first_name: name, + birth_day: '01.01.1999', + }, + ], + }, + RpcService.authService, + true + ) + .subscribe({ + next: () => { + this.router.navigate(['/']); + this.getUserInfo(); + }, + error: (err) => { + console.error(err); + }, + }); } else if (result.code === 230) { this.messageService.clear(); this.messageService.add({ @@ -194,10 +196,8 @@ export class AuthService { }, error: (error) => { console.error(error); - }, - complete: () => { this.loading = false; - } + }, }); } @@ -236,7 +236,7 @@ export class AuthService { getBalanceAmount(loyaltyPrograms: UserInfoWalletBalance[]) { return (loyaltyPrograms || []).reduce((accumulator, currentValue) => { if (currentValue.wallet.name !== 'Федеральная программа лояльности') { - return accumulator + return accumulator; } return accumulator + currentValue.balance; }, 0); diff --git a/angular/src/environments/environment.prod.ts b/angular/src/environments/environment.prod.ts index 7c134fa..3f3a311 100644 --- a/angular/src/environments/environment.prod.ts +++ b/angular/src/environments/environment.prod.ts @@ -10,16 +10,16 @@ export const environment = { defaultUrl: 'https://coffee-like-test.lk.crm4retail.ru', manifestUrl: 'https://coffee-like-test.lk.crm4retail.ru/manifest.webmanifest', firebase: { - apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY", - authDomain: "coffee-like-77bfe.firebaseapp.com", - projectId: "coffee-like-77bfe", - storageBucket: "coffee-like-77bfe.appspot.com", - messagingSenderId: "1094726277369", - appId: "1:1094726277369:web:8af560662da7700e7a2a28" + apiKey: 'AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY', + authDomain: 'coffee-like-77bfe.firebaseapp.com', + projectId: 'coffee-like-77bfe', + storageBucket: 'coffee-like-77bfe.appspot.com', + messagingSenderId: '1094726277369', + appId: '1:1094726277369:web:8af560662da7700e7a2a28', }, version: packageJson.version, appleWalletEndpoint: 'https://apple-wallet-iiko.it-retail.tech/apns/api', icardProxy: 'https://coffee-like-test.lk.crm4retail.ru/api/icard-proxy/', appleWalletSecret: 'Token F5mbzEERAznGKVbB6l', - clientName: 'coffeelike' -} + clientName: 'coffeelike', +}; diff --git a/angular/src/environments/environment.ts b/angular/src/environments/environment.ts index 0c278ea..78211e9 100644 --- a/angular/src/environments/environment.ts +++ b/angular/src/environments/environment.ts @@ -10,16 +10,16 @@ export const environment = { defaultUrl: 'http://192.168.0.179:4200', manifestUrl: 'https://coffee-like-test.lk.crm4retail.ru/manifest.webmanifest', firebase: { - apiKey: "AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY", - authDomain: "coffee-like-77bfe.firebaseapp.com", - projectId: "coffee-like-77bfe", - storageBucket: "coffee-like-77bfe.appspot.com", - messagingSenderId: "1094726277369", - appId: "1:1094726277369:web:8af560662da7700e7a2a28" + apiKey: 'AIzaSyDTb_xuMz2vDx8xGs34AJiltraKVlwmrtY', + authDomain: 'coffee-like-77bfe.firebaseapp.com', + projectId: 'coffee-like-77bfe', + storageBucket: 'coffee-like-77bfe.appspot.com', + messagingSenderId: '1094726277369', + appId: '1:1094726277369:web:8af560662da7700e7a2a28', }, version: packageJson.version, appleWalletEndpoint: 'https://apple-wallet-iiko.it-retail.tech/apns/api', icardProxy: 'https://coffee-like-test.lk.crm4retail.ru/api/icard-proxy/', appleWalletSecret: 'Token F5mbzEERAznGKVbB6l', - clientName: 'coffeelike' + clientName: 'coffeelike', };