diff --git a/angular/src/app/components/last-order/last-order.component.html b/angular/src/app/components/last-order/last-order.component.html
index f12cbb5..a5e4b7e 100644
--- a/angular/src/app/components/last-order/last-order.component.html
+++ b/angular/src/app/components/last-order/last-order.component.html
@@ -1,7 +1,7 @@
Дата:
- {{lastOrder.transactionCreateDate | date:'dd.MM.yyyyг.'}}
+ {{(lastOrder?.transactionCreateDate | date:'dd.MM.yyyyг.') || 'Данные не найдены'}}
На сумму:
- {{lastOrder.orderSum}} ₽
+ {{lastOrder?.orderSum ? lastOrder?.orderSum + ' ₽' : 'Данные не найдены'}}
- Не пришло SMS?
Отправим повторно через секунд
+
+ Не пришло SMS?
+
+ Отправим повторно через {{timeLeft}}с
+
+
+ Отправить повторно
+
+
diff --git a/angular/src/app/pages/login/login.component.scss b/angular/src/app/pages/login/login.component.scss
index 431a4f6..765c9a7 100644
--- a/angular/src/app/pages/login/login.component.scss
+++ b/angular/src/app/pages/login/login.component.scss
@@ -203,6 +203,9 @@
line-height: 16px;
text-align: center;
margin-top: 23px;
+ .resend {
+ cursor: pointer;
+ }
}
}
diff --git a/angular/src/app/pages/login/login.component.ts b/angular/src/app/pages/login/login.component.ts
index 1da638e..0a60904 100644
--- a/angular/src/app/pages/login/login.component.ts
+++ b/angular/src/app/pages/login/login.component.ts
@@ -6,6 +6,7 @@ import {
OnInit
} from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
+import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
import { MessageService } from 'primeng/api';
import { CookiesService } from 'src/app/services/cookies.service';
@@ -19,7 +20,7 @@ import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
export class LoginComponent implements OnInit, AfterViewInit {
public isShowNumber: boolean = true;
public phoneForm = new FormGroup({
- name: new FormControl('', [Validators.required]),
+ name: new FormControl('', []),
phone: new FormControl('', [Validators.required]),
});
public codeForm = new FormGroup({
@@ -29,12 +30,14 @@ export class LoginComponent implements OnInit, AfterViewInit {
code3: new FormControl('', [Validators.required]),
});
private inputIds = ['field', 'field1', 'field2', 'field3'];
+ timeLeft: number = 0;
constructor(
private cookiesService: CookiesService,
private router: Router,
private jsonrpc: JsonrpcService,
- private messageService: MessageService
+ private messageService: MessageService,
+ private _snackBar: MatSnackBar
) {}
ngOnInit(): void {}
@@ -81,29 +84,33 @@ export class LoginComponent implements OnInit, AfterViewInit {
submitNumber() {
const data = this.phoneForm.value;
this.isShowNumber = false;
+ if (this.timeLeft) {
+ this.messageService.add({
+ severity: 'custom',
+ summary: `Отправить повторно можно через ${this.timeLeft}с`,
+ });
+ return;
+ }
this.jsonrpc.rpc({
method: 'sendVerifyByPhone',
params: [data.phone]
}, RpcService.authService, false).subscribe({
next: (result) => {
- if (result.code === -1) {
- this.messageService.add({
- severity: 'error',
- summary: 'Произошла ошибка, попробуйте позже!',
- });
+ if (result.code !== 0) {
+ this._snackBar.open('Произошла ошибка! Попробуйте позже', '', {
+ duration: 3000
+ })
+ }
+ if (result.code === 0) {
+ this.timeLeft = 60;
+ const interval = setInterval(() => {
+ if(this.timeLeft > 0) {
+ this.timeLeft--;
+ } else {
+ clearInterval(interval);
+ }
+ },1000)
}
- // if (result.code === 0) {
- // this.isCodeConfirm = true;
- // this.timeLeft = 60;
- // const interval = setInterval(() => {
- // if(this.timeLeft > 0) {
- // this.timeLeft--;
- // } else {
- // clearInterval(interval);
- // }
- // },1000)
- // }
- // this.loading = false;
this.isShowNumber = false;
},
error: (error) => {
@@ -132,7 +139,10 @@ export class LoginComponent implements OnInit, AfterViewInit {
},
});
// this.phoneConfirmed.emit(null);
- } else {
+ } else if (result.code === 230) {
+ this._snackBar.open('Неверный код!', '', {
+ duration: 3000
+ })
// this.errorConfirmCode = true;
}