dev #14384 Правка ошибок отображения WPA КофеЛайк: show only one message at a time and fix header

This commit is contained in:
nikolay 2023-06-27 16:01:12 +04:00
parent 142ece15de
commit e5ae004a29
9 changed files with 62 additions and 48 deletions

View File

@ -58,6 +58,7 @@ export class DownloadAppDirective implements OnInit {
@HostListener('click', ['$event'])
async downloadApp(event: MouseEvent) {
if (!this.deferredPrompt) {
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Не поддерживается в Вашем браузере!',
@ -67,6 +68,7 @@ export class DownloadAppDirective implements OnInit {
this.deferredPrompt.prompt();
this.deferredPrompt.userChoice.then((res: any) => {
if (res.outcome === 'accepted') {
this.messageService.clear();
this.messageService.add({
severity: 'success',
summary: 'Спасибо за установку!',

View File

@ -31,7 +31,7 @@ export class RefSystemComponent implements OnInit {
true
)
)).data
this.refUrl += accountData.user_id
this.loading = false
}
@ -53,12 +53,14 @@ export class RefSystemComponent implements OnInit {
copyUrl() {
navigator.clipboard.writeText(this.refUrl)
.then(() => {
this.messageService.clear();
this.messageService.add({
severity: 'custom',
summary: 'Ссылка скопирована!',
});
})
.catch(err => {
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Произошла ошибка!',

View File

@ -38,9 +38,9 @@ export class LoginComponent implements OnInit, AfterViewInit {
private jsonrpc: JsonrpcService,
private messageService: MessageService,
private _snackBar: MatSnackBar
) {}
) { }
ngOnInit(): void {}
ngOnInit(): void { }
ngAfterViewInit() {
setTimeout(() => {
@ -72,7 +72,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
const nextInputIndex = index + 1;
if (event.target.value.length > 1) {
event.target.value = event.target.value.slice(-1);
}
if (nextInputIndex > 0 && nextInputIndex <= this.inputIds.length) {
this.inputFocusEmitter.emit(`#${this.inputIds[nextInputIndex]}`);
@ -85,6 +85,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
const data = this.phoneForm.value;
this.isShowNumber = false;
if (this.timeLeft) {
this.messageService.clear();
this.messageService.add({
severity: 'custom',
summary: `Отправить повторно можно через ${this.timeLeft}с`,
@ -95,29 +96,29 @@ export class LoginComponent implements OnInit, AfterViewInit {
method: 'sendVerifyByPhone',
params: [data.phone]
}, RpcService.authService, false).subscribe({
next: (result) => {
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)
}
this.isShowNumber = false;
},
error: (error) => {
console.error('Error: ', error);
next: (result) => {
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)
}
this.isShowNumber = false;
},
error: (error) => {
console.error('Error: ', error);
}
}
);
setTimeout(() => {
this.inputFocusEmitter.emit(`#${this.inputIds[0]}`);
@ -130,28 +131,28 @@ export class LoginComponent implements OnInit, AfterViewInit {
method: 'getTokenByPhone',
params: [this.phoneForm.value.phone, Object.values(data).join('')]
}, RpcService.authService, false).subscribe({
next: (result) => {
if (result.code === 0) {
this.cookiesService.setCookie('token', result?.data?.token);
this.router.navigate(['/'], {
queryParams: {
token: result?.data?.token
},
});
// this.phoneConfirmed.emit(null);
} else if (result.code === 230) {
this._snackBar.open('Неверный код!', '', {
duration: 3000
})
// this.errorConfirmCode = true;
}
},
error: (error) => {
console.error(error);
next: (result) => {
if (result.code === 0) {
this.cookiesService.setCookie('token', result?.data?.token);
this.router.navigate(['/'], {
queryParams: {
token: result?.data?.token
},
});
// this.phoneConfirmed.emit(null);
} else if (result.code === 230) {
this._snackBar.open('Неверный код!', '', {
duration: 3000
})
// this.errorConfirmCode = true;
}
},
error: (error) => {
console.error(error);
}
}
);
}

View File

@ -61,12 +61,13 @@ export class MainComponent implements OnInit {
const userAgent = window.navigator.userAgent.toLowerCase();
const ios = /iphone|ipod|ipad/.test(userAgent);
if (ios) {
this.messageService.clear();
this.messageService.add({
severity: 'custom',
summary: `Чтобы получать уведомления, добавьте карту в Apple Wallet`,
life: 5000,
});
// var permissionData = window.safari.pushNotification.permission('web.com.example.domain');
// $scope.checkRemotePermission(permissionData);
} else {

View File

@ -44,6 +44,7 @@
display: flex;
align-items: center;
gap: 10px;
min-width: 40px;
}
.menu {
position: relative;

View File

@ -42,6 +42,7 @@ export class GuestCardComponent implements OnInit {
const userAgent = window.navigator.userAgent.toLowerCase();
const ios = /iphone|ipod|ipad/.test(userAgent);
if (ios) {
this.messageService.clear();
this.messageService.add({
severity: 'custom',
summary: `Чтобы получать уведомления, добавьте карту в Apple Wallet`,

View File

@ -104,10 +104,10 @@ export class LoginComponent implements OnInit {
if (this.phoneForm.invalid) {
this.phoneForm.markAsTouched();
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Введите имя и телефон',
life: 5000,
summary: 'Введите имя и телефон',
});
return;

View File

@ -81,6 +81,7 @@ export class AuthService {
}
})
} else if (value && value.error && value.error.code > 1) {
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Произошла ошибка! Попробуйте позже',
@ -110,6 +111,7 @@ export class AuthService {
sendVerifyByPhone(phone: string) {
if (this.timeLeft) {
this.messageService.clear();
this.messageService.add({
severity: 'custom',
summary: `Отправить повторно можно через ${this.timeLeft}с`,
@ -130,6 +132,7 @@ export class AuthService {
.subscribe({
next: (result) => {
if (result.code !== 0) {
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Произошла ошибка! Попробуйте позже',
@ -192,6 +195,7 @@ export class AuthService {
},
})
} else if (result.code === 230) {
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Неверный код!',

View File

@ -50,6 +50,7 @@ export class MessagingService {
)
.subscribe({
next: () => {
this.messageService.clear();
this.messageService.add({
severity: 'custom',
summary: 'Спасибо за подписку!',
@ -57,6 +58,7 @@ export class MessagingService {
},
error: (err) => {
console.error('Error: ', err);
this.messageService.clear();
this.messageService.add({
severity: 'error',
summary: 'Произошла ошибка, попробуйте позже',