diff --git a/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts b/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts index 2dcb788..45e1a68 100644 --- a/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts +++ b/angular/src/app/presentation-options/default-option/components/navbar/navbar.component.ts @@ -59,7 +59,9 @@ export class NavbarComponent implements OnInit { } addToWallet = () => { - this.appleWalletService.addCardToWallet(); + if (this.authService.userInfo) { + this.appleWalletService.addCardToWallet(this.authService.userInfo); + } } deleteToken = (): void => { 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 f864e21..c4b217d 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,3 +1,4 @@ + import { Component, OnInit } from '@angular/core'; import { MatBottomSheet } from '@angular/material/bottom-sheet'; import { ExitComponent } from 'src/app/components/exit/exit.component'; @@ -34,8 +35,6 @@ export class GuestCardComponent implements OnInit { ngOnInit(): void { this.negativeBalance = !Array.isArray(this.authService.userInfo?.walletBalances); this.showBack = getTypeDevice() === DeviceType.android; - - this.requestPermission(); } requestPermission() { diff --git a/angular/src/app/presentation-options/default-option/pages/login/login.component.html b/angular/src/app/presentation-options/default-option/pages/login/login.component.html index 49318f8..bf0ed47 100644 --- a/angular/src/app/presentation-options/default-option/pages/login/login.component.html +++ b/angular/src/app/presentation-options/default-option/pages/login/login.component.html @@ -30,13 +30,13 @@ +

+ Используя приложение, вы принимаете + условия и соглашаетесь на получение + рекламно-информационных сообщений +

- -

- Используя приложение, вы принимаете условия - соглашения и соглашаетесь на получение рекламно-информационных - сообщений -

+
diff --git a/angular/src/app/presentation-options/default-option/pages/login/login.component.scss b/angular/src/app/presentation-options/default-option/pages/login/login.component.scss index 51336ef..bc1a66e 100644 --- a/angular/src/app/presentation-options/default-option/pages/login/login.component.scss +++ b/angular/src/app/presentation-options/default-option/pages/login/login.component.scss @@ -16,9 +16,10 @@ } .agree-info { text-align: center; - margin: 0 auto; - margin-top: 40px; + margin: 0 auto; max-width: 80%; + font-size: 12px; + margin-bottom: 20px; } .logo { text-align: center; diff --git a/angular/src/app/services/apple-wallet.service.ts b/angular/src/app/services/apple-wallet.service.ts index f03d937..1fb65cd 100644 --- a/angular/src/app/services/apple-wallet.service.ts +++ b/angular/src/app/services/apple-wallet.service.ts @@ -5,6 +5,7 @@ import { environment } from 'src/environments/environment'; import { CookiesService } from './cookies.service'; import { RpcService, JsonrpcService } from 'src/app/services/jsonrpc.service'; import { DOCUMENT } from '@angular/common'; +import { UserInfo } from 'src/app/interface/data'; @Injectable({ providedIn: 'root', @@ -41,35 +42,50 @@ export class AppleWalletService { } - async addCardToWallet() { + async addCardToWallet(userInfo: UserInfo) { const token = this.cookiesService.getItem('token'); - try { - const accountData = ( - await lastValueFrom( - this.jsonrpc.rpc( - { - method: 'getTokenData', - params: [], - }, - RpcService.authService, - true - ) - ) - ).data; - if (token && accountData.user_id) { - this.generateCard(token, accountData.user_id).subscribe({ - next: (res: any) => { - this.document.location.href = res.url; - }, - error: (err) => { - console.log('Error: ', err); - }, - }); - } + try { + this.jsonrpc.rpc( + { + method: 'updateAdditionalInfo', + params: [ + { + first_name: userInfo.name, + birth_day: '01.01.1999' + }, + ], + }, + RpcService.authService, + true + ).subscribe({ + next: async () => { + const accountData = ( + await lastValueFrom( + this.jsonrpc.rpc( + { + method: 'getTokenData', + params: [], + }, + RpcService.authService, + true + ) + ) + ).data; + + if (token && accountData.user_id) { + this.generateCard(token, accountData.user_id).subscribe({ + next: (res: any) => { + this.document.location.href = res.url; + }, + error: (err) => { + console.log('Error: ', err); + }, + }); + } + }}); } catch (e) { console.log(e); } - } } diff --git a/angular/src/app/services/auth.service.ts b/angular/src/app/services/auth.service.ts index 21dc06b..3fd2333 100644 --- a/angular/src/app/services/auth.service.ts +++ b/angular/src/app/services/auth.service.ts @@ -42,7 +42,7 @@ export class AuthService { private jsonrpc: JsonrpcService, private messageService: MessageService, private router: Router, - private appleWalletService: AppleWalletService, + private appleWalletService: AppleWalletService, ) { this.getCurrentQuarterOfYear(); } @@ -75,30 +75,30 @@ export class AuthService { if (value && value.customer_info && value.customer_info.errorCode === 'Customer_CustomerNotFound' || !this.userHasData(value?.customer_info)) { this.router.navigate(['create_user']); - return rej(null); + return rej(null); } else if (value && value.error && value.error.code > 1) { this.messageService.clear(); this.messageService.add({ severity: 'error', summary: 'Произошла ошибка! Попробуйте позже', }); - return rej(null); + return rej(null); } else if (value && value.customer_info) { this.userInfo = value.customer_info; this.cookiesService.setCookie('phone-number', this.userInfo!.phone?.slice(2)); } - res(null); + res(null); }, error: (e) => { this.error = e; - rej(e); + rej(e); }, complete: () => { this.loading = false; }, }) - ); + ); } userHasData(user?: UserInfo) { @@ -176,12 +176,12 @@ export class AuthService { if (result.code === 0) { this.cookiesService.setCookie('token', result?.data?.token); this.router.navigate(['/']); - + await this.getUserInfo(); - - if(getTypeDevice() === DeviceType.ios) { - this.appleWalletService.addCardToWallet(); - } + + if (getTypeDevice() === DeviceType.ios) { + this.appleWalletService.addCardToWallet(this.userInfo!); + } } else if (result.code === 230) { this.messageService.clear(); this.messageService.add({ @@ -279,9 +279,9 @@ export class AuthService { next: async () => { this.router.navigate(['/']); await this.getUserInfo(); - if(getTypeDevice() === DeviceType.ios) { - this.appleWalletService.addCardToWallet(); - } + if (getTypeDevice() === DeviceType.ios) { + this.appleWalletService.addCardToWallet(this.userInfo!); + } }, error: () => { this.loading = false;