dev #13995
This commit is contained in:
parent
af60b55e94
commit
42b46bc478
@ -52,6 +52,7 @@ import {
|
||||
MatBottomSheetModule,
|
||||
MatBottomSheetRef,
|
||||
} from '@angular/material/bottom-sheet';
|
||||
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@ -109,6 +110,7 @@ import {
|
||||
MatInputModule,
|
||||
MatSnackBarModule,
|
||||
MatBottomSheetModule,
|
||||
MatProgressSpinnerModule
|
||||
],
|
||||
providers: [
|
||||
DialogService,
|
||||
|
||||
@ -8,16 +8,21 @@
|
||||
<div class="guest-card">
|
||||
<div class="guest-card__qr" (click)="qrCodeClick()">
|
||||
<qr-code
|
||||
*ngIf="user; else spinner"
|
||||
[value]="user?.customer_info?.phone.substr(2) || 'Данные не найдены'"
|
||||
[margin]="0"
|
||||
[size]="qrCodeSize"
|
||||
errorCorrectionLevel="M"
|
||||
></qr-code>
|
||||
|
||||
</div>
|
||||
<div class="guest-card__user-description">
|
||||
За период с 11.01.2023 по 31.03.2023 вам начислено
|
||||
<span>360 бонусов</span>
|
||||
Текущий баланс бонусов:
|
||||
<span *ngIf="user">
|
||||
{{
|
||||
getBalanceAmount(user?.customer_info?.walletBalances)
|
||||
}}
|
||||
бонусов</span
|
||||
>
|
||||
</div>
|
||||
<app-accordion header="Условия начисления бонусов">
|
||||
<p>
|
||||
@ -151,3 +156,7 @@
|
||||
>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #spinner>
|
||||
<mat-spinner></mat-spinner>
|
||||
</ng-template>
|
||||
|
||||
@ -8,9 +8,7 @@ import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import moment from 'moment';
|
||||
|
||||
interface Moment extends moment.Moment {
|
||||
|
||||
}
|
||||
interface Moment extends moment.Moment {}
|
||||
|
||||
@Component({
|
||||
selector: 'app-guest-card',
|
||||
@ -33,10 +31,14 @@ export class GuestCardComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
const token = this.cookiesService.getItem('token')
|
||||
this.customerInfo = this.wpJsonService.getCustomerInfo(environment.systemId, token || '', environment.icardProxy)
|
||||
this.purchases = this.getPurchases()
|
||||
// this.purchases.subscribe((value) => console.log(value));
|
||||
const token = this.cookiesService.getItem('token');
|
||||
this.customerInfo = this.wpJsonService.getCustomerInfo(
|
||||
environment.systemId,
|
||||
token || '',
|
||||
environment.icardProxy
|
||||
);
|
||||
this.purchases = this.getPurchases();
|
||||
this.purchases.subscribe((value) => console.log(value));
|
||||
}
|
||||
|
||||
qrCodeClick() {
|
||||
@ -49,20 +51,38 @@ export class GuestCardComponent implements OnInit {
|
||||
}
|
||||
|
||||
logout() {
|
||||
const bottomSheet = this._bottomSheet.open(ExitComponent)
|
||||
const bottomSheet = this._bottomSheet.open(ExitComponent);
|
||||
bottomSheet.afterDismissed().subscribe({
|
||||
next: (val) => {
|
||||
if (val) {
|
||||
this.deleteToken();
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getPurchases(start: Date | Moment = moment().startOf('month'), end: Date | Moment = moment()): Observable<any> {
|
||||
const token = this.cookiesService.getItem('token')
|
||||
const delta = moment(end).diff(moment(start), 'days')
|
||||
return this.wpJsonService.getTransactionsInfo(environment.systemId, token ?? '', environment.icardProxy)
|
||||
getPurchases(
|
||||
start: Date | Moment = moment().startOf('month'),
|
||||
end: Date | Moment = moment()
|
||||
): Observable<any> {
|
||||
const token = this.cookiesService.getItem('token');
|
||||
const delta = moment(end).diff(moment(start), 'days');
|
||||
return this.wpJsonService.getTransactionsInfo(
|
||||
environment.systemId,
|
||||
token ?? '',
|
||||
environment.icardProxy
|
||||
);
|
||||
}
|
||||
|
||||
getBalanceAmount(loyaltyPrograms: any[]) {
|
||||
console.log(loyaltyPrograms);
|
||||
|
||||
return loyaltyPrograms.reduce(
|
||||
(accumulator, currentValue) => {
|
||||
return accumulator + currentValue.balance
|
||||
},
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user