parent
00a47756b2
commit
1a503b3163
@ -7,13 +7,13 @@ import { AppComponent } from './app.component';
|
|||||||
import { MainComponent } from './pages/main/main.component';
|
import { MainComponent } from './pages/main/main.component';
|
||||||
import { NavbarComponent } from './components/navbar/navbar.component';
|
import { NavbarComponent } from './components/navbar/navbar.component';
|
||||||
import { CardComponent } from './components/card/card.component';
|
import { CardComponent } from './components/card/card.component';
|
||||||
import {InputMaskModule} from "primeng/inputmask";
|
import { InputMaskModule } from 'primeng/inputmask';
|
||||||
import { AuthComponent } from './pages/account/auth/auth.component';
|
import { AuthComponent } from './pages/account/auth/auth.component';
|
||||||
import {ProgressSpinnerModule} from "primeng/progressspinner";
|
import { ProgressSpinnerModule } from 'primeng/progressspinner';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { AccountComponent } from './pages/account/account.component';
|
import { AccountComponent } from './pages/account/account.component';
|
||||||
import { ExitComponent } from './components/exit/exit.component';
|
import { ExitComponent } from './components/exit/exit.component';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { DialogService } from 'primeng/dynamicdialog';
|
import { DialogService } from 'primeng/dynamicdialog';
|
||||||
import { BonusProgramComponent } from './pages/account/bonus-program/bonus-program.component';
|
import { BonusProgramComponent } from './pages/account/bonus-program/bonus-program.component';
|
||||||
@ -23,59 +23,64 @@ import { ServiceWorkerModule } from '@angular/service-worker';
|
|||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import { AngularFireModule } from '@angular/fire/compat';
|
import { AngularFireModule } from '@angular/fire/compat';
|
||||||
import { AngularFireMessagingModule } from '@angular/fire/compat/messaging';
|
import { AngularFireMessagingModule } from '@angular/fire/compat/messaging';
|
||||||
import {ToastModule} from 'primeng/toast';
|
import { ToastModule } from 'primeng/toast';
|
||||||
import { MessageService } from 'primeng/api';
|
import { MessageService } from 'primeng/api';
|
||||||
import { FooterButtonsComponent } from './components/footer-buttons/footer-buttons.component';
|
import { FooterButtonsComponent } from './components/footer-buttons/footer-buttons.component';
|
||||||
import { UserDataComponent } from './pages/account/user-data/user-data.component';
|
import { UserDataComponent } from './pages/account/user-data/user-data.component';
|
||||||
import { RefSystemComponent } from './pages/account/ref-system/ref-system.component';
|
import { RefSystemComponent } from './pages/account/ref-system/ref-system.component';
|
||||||
import { QRCodeModule } from 'angularx-qrcode';
|
import { QRCodeModule } from 'angularx-qrcode';
|
||||||
import { ShareButtonsModule } from 'ngx-sharebuttons/buttons';
|
import { ShareButtonsModule } from 'ngx-sharebuttons/buttons';
|
||||||
import { ShareIconsModule } from 'ngx-sharebuttons/icons';
|
import { ShareIconsModule } from 'ngx-sharebuttons/icons';
|
||||||
import { MessagingService } from './services/messaging.service';
|
import { MessagingService } from './services/messaging.service';
|
||||||
import { NotFoundComponent } from './pages/not-found/not-found.component';
|
import { NotFoundComponent } from './pages/not-found/not-found.component';
|
||||||
import { ProductsComponent } from './pages/products/products.component';
|
import { ProductsComponent } from './pages/products/products.component';
|
||||||
import { CartComponent } from './pages/cart/cart.component';
|
import { CartComponent } from './pages/cart/cart.component';
|
||||||
import {ListboxModule} from 'primeng/listbox';
|
import { ListboxModule } from 'primeng/listbox';
|
||||||
import { ProductModalComponent } from './components/product-modal/product-modal.component';
|
import { ProductModalComponent } from './components/product-modal/product-modal.component';
|
||||||
import { CheckboxGroupComponent } from './components/checkbox-group/checkbox-group.component';
|
import { CheckboxGroupComponent } from './components/checkbox-group/checkbox-group.component';
|
||||||
import { TreeSelectModule } from 'primeng/treeselect';
|
import { TreeSelectModule } from 'primeng/treeselect';
|
||||||
import { UserDataOrderComponent } from './components/user-data-order/user-data-order.component';
|
import { UserDataOrderComponent } from './components/user-data-order/user-data-order.component';
|
||||||
import {DropdownModule} from "primeng/dropdown";
|
import { DropdownModule } from 'primeng/dropdown';
|
||||||
import {SelectButtonModule} from 'primeng/selectbutton';
|
import { SelectButtonModule } from 'primeng/selectbutton';
|
||||||
import { CalendarModule } from 'primeng/calendar';
|
import { CalendarModule } from 'primeng/calendar';
|
||||||
import {MatIconModule} from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { InfoComponent } from './pages/info/info.component';
|
import { InfoComponent } from './pages/info/info.component';
|
||||||
import { MdbCarouselModule } from 'mdb-angular-ui-kit/carousel';
|
import { MdbCarouselModule } from 'mdb-angular-ui-kit/carousel';
|
||||||
import { StoreModule } from '@ngrx/store';
|
import { StoreModule } from '@ngrx/store';
|
||||||
import { configReducer } from './state/config/config.reducer';
|
import { configReducer } from './state/config/config.reducer';
|
||||||
import { EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
import { ConfigEffects } from './state/config/config.effects';
|
import { ConfigEffects } from './state/config/config.effects';
|
||||||
import {PaginatorModule} from 'primeng/paginator';
|
import { PaginatorModule } from 'primeng/paginator';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import { InputTextModule } from 'primeng/inputtext';
|
||||||
import { ChangeQuantityComponent } from './components/change-quantity/change-quantity.component';
|
import { ChangeQuantityComponent } from './components/change-quantity/change-quantity.component';
|
||||||
import { MenuComponent } from './components/menu/menu.component';
|
import { MenuComponent } from './components/menu/menu.component';
|
||||||
import { SidebarModule } from 'primeng/sidebar';
|
import { SidebarModule } from 'primeng/sidebar';
|
||||||
import {RippleModule} from 'primeng/ripple';
|
import { RippleModule } from 'primeng/ripple';
|
||||||
import {MatTabsModule} from '@angular/material/tabs';
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
import { ModifierComponent } from './components/modifier/modifier.component';
|
import { ModifierComponent } from './components/modifier/modifier.component';
|
||||||
import { OptionComponent } from './components/option/option.component';
|
import { OptionComponent } from './components/option/option.component';
|
||||||
import { ChangeQuantityOptionDirective } from './directives/change-quantity-option.directive';
|
import { ChangeQuantityOptionDirective } from './directives/change-quantity-option.directive';
|
||||||
import {MatSelectModule} from '@angular/material/select';
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
import {MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS} from '@angular/material/form-field';
|
import {
|
||||||
|
MatFormFieldModule,
|
||||||
|
MAT_FORM_FIELD_DEFAULT_OPTIONS,
|
||||||
|
} from '@angular/material/form-field';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import {MatBottomSheetModule} from '@angular/material/bottom-sheet';
|
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
|
||||||
import { TerminalListComponent } from './components/terminal-list/terminal-list.component';
|
import { TerminalListComponent } from './components/terminal-list/terminal-list.component';
|
||||||
import {MatButtonModule} from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import {MatListModule} from '@angular/material/list';
|
import { MatListModule } from '@angular/material/list';
|
||||||
import {MatSnackBarModule} from '@angular/material/snack-bar';
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
import { SnackBarComponent } from './components/snack-bar/snack-bar.component';
|
import { SnackBarComponent } from './components/snack-bar/snack-bar.component';
|
||||||
|
import {MatDialogModule} from '@angular/material/dialog';
|
||||||
|
import { PurchaseInfoComponent } from './components/purchase-info/purchase-info.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'products', pathMatch: 'full' },
|
{ path: '', redirectTo: 'products', pathMatch: 'full' },
|
||||||
{ path: 'products', component: ProductsComponent },
|
{ path: 'products', component: ProductsComponent },
|
||||||
// { path: 'cart', component: CartComponent },
|
// { path: 'cart', component: CartComponent },
|
||||||
{ path: 'account', component: AccountComponent },
|
{ path: 'account', component: AccountComponent },
|
||||||
{ path: '**', component: NotFoundComponent }
|
{ path: '**', component: NotFoundComponent },
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -106,13 +111,14 @@ const routes: Routes = [
|
|||||||
OptionComponent,
|
OptionComponent,
|
||||||
ChangeQuantityOptionDirective,
|
ChangeQuantityOptionDirective,
|
||||||
TerminalListComponent,
|
TerminalListComponent,
|
||||||
SnackBarComponent
|
SnackBarComponent,
|
||||||
|
PurchaseInfoComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
RouterModule.forRoot(routes, {
|
RouterModule.forRoot(routes, {
|
||||||
scrollPositionRestoration: 'enabled'
|
scrollPositionRestoration: 'enabled',
|
||||||
}),
|
}),
|
||||||
InputMaskModule,
|
InputMaskModule,
|
||||||
ProgressSpinnerModule,
|
ProgressSpinnerModule,
|
||||||
@ -124,7 +130,7 @@ const routes: Routes = [
|
|||||||
enabled: environment.production,
|
enabled: environment.production,
|
||||||
// Register the ServiceWorker as soon as the application is stable
|
// Register the ServiceWorker as soon as the application is stable
|
||||||
// or after 30 seconds (whichever comes first).
|
// or after 30 seconds (whichever comes first).
|
||||||
registrationStrategy: 'registerWhenStable:30000'
|
registrationStrategy: 'registerWhenStable:30000',
|
||||||
}),
|
}),
|
||||||
AngularFireModule.initializeApp(environment.firebase),
|
AngularFireModule.initializeApp(environment.firebase),
|
||||||
AngularFireMessagingModule,
|
AngularFireMessagingModule,
|
||||||
@ -132,7 +138,7 @@ const routes: Routes = [
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
QRCodeModule,
|
QRCodeModule,
|
||||||
ShareButtonsModule.withConfig({
|
ShareButtonsModule.withConfig({
|
||||||
debug: true
|
debug: true,
|
||||||
}),
|
}),
|
||||||
ShareIconsModule,
|
ShareIconsModule,
|
||||||
ListboxModule,
|
ListboxModule,
|
||||||
@ -142,7 +148,7 @@ const routes: Routes = [
|
|||||||
CalendarModule,
|
CalendarModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
MdbCarouselModule,
|
MdbCarouselModule,
|
||||||
StoreModule.forRoot({config: configReducer}),
|
StoreModule.forRoot({ config: configReducer }),
|
||||||
EffectsModule.forRoot([ConfigEffects]),
|
EffectsModule.forRoot([ConfigEffects]),
|
||||||
PaginatorModule,
|
PaginatorModule,
|
||||||
InputTextModule,
|
InputTextModule,
|
||||||
@ -155,9 +161,18 @@ const routes: Routes = [
|
|||||||
MatBottomSheetModule,
|
MatBottomSheetModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatListModule,
|
MatListModule,
|
||||||
MatSnackBarModule
|
MatSnackBarModule,
|
||||||
|
MatDialogModule
|
||||||
],
|
],
|
||||||
providers: [DialogService, MessageService, MessagingService, {provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}} ],
|
providers: [
|
||||||
bootstrap: [AppComponent]
|
DialogService,
|
||||||
|
MessageService,
|
||||||
|
MessagingService,
|
||||||
|
{
|
||||||
|
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
|
||||||
|
useValue: { appearance: 'outline' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
bootstrap: [AppComponent],
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule {}
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
<h2 mat-dialog-title>{{ moment(purchaseInfo.date).format("DD.MM.YYYY") }}</h2>
|
||||||
|
<mat-dialog-content>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr
|
||||||
|
*ngFor="let good of purchaseInfo.goods_list"
|
||||||
|
class="woocommerce-orders-table__row woocommerce-orders-table__row--status-processing order"
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-name"
|
||||||
|
data-title="Название"
|
||||||
|
>
|
||||||
|
{{ good.name }}
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-price"
|
||||||
|
data-title="Цена"
|
||||||
|
>
|
||||||
|
{{ good.price }}
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-quantity"
|
||||||
|
data-title="Количество"
|
||||||
|
>
|
||||||
|
{{ good.quantity }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</mat-dialog-content>
|
||||||
|
<mat-dialog-actions>
|
||||||
|
<span class="amount">Сумма: {{ purchaseInfo.sum }}</span>
|
||||||
|
<button mat-stroked-button mat-dialog-close>Закрыть</button>
|
||||||
|
</mat-dialog-actions>
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
:host {
|
||||||
|
.woocommerce-orders-table {
|
||||||
|
&__cell {
|
||||||
|
padding: 8px 4px;
|
||||||
|
border-bottom: 2px solid #dee2e6;
|
||||||
|
text-align: right !important;
|
||||||
|
display: block;
|
||||||
|
&::before {
|
||||||
|
content: attr(data-title) ": ";
|
||||||
|
font-weight: 700;
|
||||||
|
float: left;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&__row {
|
||||||
|
display: block;
|
||||||
|
&:nth-child(even) {
|
||||||
|
background: #ebebeb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// &__cell-order-actions::before {
|
||||||
|
// display: none;
|
||||||
|
// }
|
||||||
|
&__cell-order-actions {
|
||||||
|
&.red-color {
|
||||||
|
color: #ed0000;
|
||||||
|
}
|
||||||
|
&.green-color {
|
||||||
|
color: #00a700;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&__cell-order-number a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #009688;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.amount {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-dialog-actions {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { PurchaseInfoComponent } from './purchase-info.component';
|
||||||
|
|
||||||
|
describe('PurchaseInfoComponent', () => {
|
||||||
|
let component: PurchaseInfoComponent;
|
||||||
|
let fixture: ComponentFixture<PurchaseInfoComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ PurchaseInfoComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(PurchaseInfoComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import { Component, OnInit, Inject } from '@angular/core';
|
||||||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { PurchaseInfo } from 'src/app/interface/data';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-purchase-info',
|
||||||
|
templateUrl: './purchase-info.component.html',
|
||||||
|
styleUrls: ['./purchase-info.component.scss']
|
||||||
|
})
|
||||||
|
export class PurchaseInfoComponent implements OnInit {
|
||||||
|
public purchaseInfo!: PurchaseInfo;
|
||||||
|
readonly moment = moment;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public dialogRef: MatDialogRef<PurchaseInfoComponent>,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: {purchaseInfo: PurchaseInfo},
|
||||||
|
) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.purchaseInfo = this.data.purchaseInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -56,10 +56,25 @@ export interface Purchase {
|
|||||||
// ID: string;
|
// ID: string;
|
||||||
// Transactions: Transaction[];
|
// Transactions: Transaction[];
|
||||||
// IsSingleTransaction?: boolean;
|
// IsSingleTransaction?: boolean;
|
||||||
|
orderNumber: number;
|
||||||
transactionCreateDate: string;
|
transactionCreateDate: string;
|
||||||
orderSum: number;
|
orderSum: number;
|
||||||
transactionSum: number;
|
transactionSum: number;
|
||||||
transactionType: 'CancelPayFromWallet' | 'PayFromWallet' | 'RefillWallet';
|
transactionType: 'CancelPayFromWallet' | 'PayFromWallet' | 'RefillWallet';
|
||||||
|
more_info: PurchaseInfo | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PurchaseInfo {
|
||||||
|
date: string;
|
||||||
|
goods_list: [
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
price: number;
|
||||||
|
quantity: number;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
number: string;
|
||||||
|
sum: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Transaction {
|
export interface Transaction {
|
||||||
@ -82,10 +97,10 @@ export interface OrderStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DeliveryType {
|
export interface DeliveryType {
|
||||||
// cost: number;
|
// cost: number;
|
||||||
// title: string;
|
// title: string;
|
||||||
// id: number;
|
// id: number;
|
||||||
// type: string;
|
// type: string;
|
||||||
name: string;
|
name: string;
|
||||||
iikoId: string;
|
iikoId: string;
|
||||||
iikoName: string;
|
iikoName: string;
|
||||||
|
|||||||
@ -57,7 +57,7 @@ export class BonusProgramComponent implements OnInit {
|
|||||||
this.loadingBonuses = true;
|
this.loadingBonuses = true;
|
||||||
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({
|
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({
|
||||||
next: (res) => {
|
next: (res) => {
|
||||||
if (res.customer_info.errorCode === 'Customer_CustomerNotFound') {
|
if (res.customer_info?.errorCode === 'Customer_CustomerNotFound' || 'Error' in res) {
|
||||||
// this._snackBar.open('Пользователь не найден в системе! Обратитесь к руководству', 'Ок')
|
// this._snackBar.open('Пользователь не найден в системе! Обратитесь к руководству', 'Ок')
|
||||||
this.loadingBonuses = false;
|
this.loadingBonuses = false;
|
||||||
return
|
return
|
||||||
|
|||||||
@ -21,10 +21,15 @@
|
|||||||
<span class="nobr">Сумма чека</span>
|
<span class="nobr">Сумма чека</span>
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
class="woocommerce-orders-table__header woocommerce-orders-table__header-order-actions"
|
class="woocommerce-orders-table__header woocommerce-orders-table__header-order-bonuses"
|
||||||
>
|
>
|
||||||
<span class="nobr">Бонусы</span>
|
<span class="nobr">Бонусы</span>
|
||||||
</th>
|
</th>
|
||||||
|
<th
|
||||||
|
class="woocommerce-orders-table__header woocommerce-orders-table__header-order-actions"
|
||||||
|
>
|
||||||
|
<span class="nobr">Действия</span>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -55,7 +60,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-actions"
|
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-bonuses"
|
||||||
data-title="Бонусы"
|
data-title="Бонусы"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'red-color': purchase.transactionSum ? purchase.transactionSum < 0 : false,
|
'red-color': purchase.transactionSum ? purchase.transactionSum < 0 : false,
|
||||||
@ -64,6 +69,11 @@
|
|||||||
>
|
>
|
||||||
{{ purchase.transactionSum }}
|
{{ purchase.transactionSum }}
|
||||||
</td>
|
</td>
|
||||||
|
<td *ngIf="purchase.more_info" class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-actions" data-title="Действия">
|
||||||
|
<button mat-stroked-button (click)="showPurchaseInfo(purchase.more_info)" >
|
||||||
|
Подробнее
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 400px;
|
// max-width: 400px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
thead {
|
thead {
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { Page, Purchase, PurchaseInfo } from 'src/app/interface/data';
|
||||||
import { Page, Purchase } from 'src/app/interface/data';
|
|
||||||
import * as moment from 'moment-timezone';
|
import * as moment from 'moment-timezone';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
|
||||||
import { WpJsonService } from 'src/app/services/wp-json.service';
|
import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { CookiesService } from 'src/app/services/cookies.service';
|
import { CookiesService } from 'src/app/services/cookies.service';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { PurchaseInfoComponent } from 'src/app/components/purchase-info/purchase-info.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-orders',
|
selector: 'app-orders',
|
||||||
templateUrl: './orders.component.html',
|
templateUrl: './orders.component.html',
|
||||||
styleUrls: ['./orders.component.scss']
|
styleUrls: ['./orders.component.scss'],
|
||||||
})
|
})
|
||||||
export class OrdersComponent implements OnInit {
|
export class OrdersComponent implements OnInit {
|
||||||
@Input() currentPage!: Page;
|
@Input() currentPage!: Page;
|
||||||
@Input() handleHttpError!: (error: HttpErrorResponse) => void;
|
@Input() handleHttpError!: (error: HttpErrorResponse) => void;
|
||||||
@Output() deauthorization = new EventEmitter<boolean>(false)
|
@Output() deauthorization = new EventEmitter<boolean>(false);
|
||||||
public lastViewOrder: number = 3;
|
public lastViewOrder: number = 3;
|
||||||
public ordersLoadingStatus: boolean = true;
|
public ordersLoadingStatus: boolean = true;
|
||||||
readonly moment = moment;
|
readonly moment = moment;
|
||||||
@ -25,45 +25,80 @@ export class OrdersComponent implements OnInit {
|
|||||||
public purchasesShortArray: Purchase[] = [];
|
public purchasesShortArray: Purchase[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
|
||||||
private router: Router,
|
|
||||||
private jsonrpc: JsonrpcService,
|
|
||||||
private wpJsonService: WpJsonService,
|
private wpJsonService: WpJsonService,
|
||||||
private cookiesService: CookiesService,
|
private cookiesService: CookiesService,
|
||||||
) { }
|
public dialog: MatDialog
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.getOrders()
|
this.getOrders();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOrders() {
|
async getOrders() {
|
||||||
const token = this.cookiesService.getItem('token')
|
const token = this.cookiesService.getItem('token');
|
||||||
if (!token) {
|
if (!token) {
|
||||||
this.cookiesService.deleteCookie('token')
|
this.cookiesService.deleteCookie('token');
|
||||||
this.deauthorization.emit(true)
|
this.deauthorization.emit(true);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const customerInfo = (await lastValueFrom(
|
const customerInfo = await lastValueFrom(
|
||||||
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy)
|
this.wpJsonService.getCustomerInfo(
|
||||||
))
|
environment.systemId,
|
||||||
if (customerInfo.customer_info.errorCode === 'Customer_CustomerNotFound') {
|
token,
|
||||||
|
environment.icardProxy
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
customerInfo.customer_info?.errorCode === 'Customer_CustomerNotFound' ||
|
||||||
|
'Error' in customerInfo
|
||||||
|
) {
|
||||||
this.ordersLoadingStatus = false;
|
this.ordersLoadingStatus = false;
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const purchases: Purchase[] = (await lastValueFrom(
|
const purchases: Purchase[] = (
|
||||||
this.wpJsonService.getTransactions(environment.systemId, token, environment.icardProxy, 30)
|
await lastValueFrom(
|
||||||
))[customerInfo.customer_info.id];
|
this.wpJsonService.getTransactions(
|
||||||
|
environment.systemId,
|
||||||
|
token,
|
||||||
|
environment.icardProxy,
|
||||||
|
30
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)[customerInfo.customer_info?.id];
|
||||||
|
|
||||||
this.purchases = purchases.map<Purchase>((purchase) => {
|
const purchasesInfo: PurchaseInfo[] = (
|
||||||
// const id = purchase.ID.slice(0,36).toLowerCase();
|
await lastValueFrom(
|
||||||
// purchase.Transactions = transactions.filter((transaction) => {
|
this.wpJsonService.getTransactionsInfo(
|
||||||
// const same = transaction.Purchase === id;
|
environment.systemId,
|
||||||
// transaction.HasPurchase = same;
|
token,
|
||||||
// return same;
|
environment.icardProxy,
|
||||||
// });
|
30
|
||||||
return purchase;
|
)
|
||||||
}).filter((purchase: Purchase) => ['PayFromWallet', 'CancelPayFromWallet', 'RefillWallet'].includes(purchase.transactionType));
|
)
|
||||||
this.purchasesShortArray = this.purchases.slice(0, this.lastViewOrder)
|
)['purchase'];
|
||||||
|
|
||||||
|
this.purchases = purchases
|
||||||
|
.map<Purchase>((purchase) => {
|
||||||
|
// const id = purchase.ID.slice(0,36).toLowerCase();
|
||||||
|
// purchase.Transactions = transactions.filter((transaction) => {
|
||||||
|
// const same = transaction.Purchase === id;
|
||||||
|
// transaction.HasPurchase = same;
|
||||||
|
// return same;
|
||||||
|
// });
|
||||||
|
purchase.more_info =
|
||||||
|
purchasesInfo.find(
|
||||||
|
(purchaseInfo: PurchaseInfo) =>
|
||||||
|
Number(purchaseInfo.number) === purchase.orderNumber
|
||||||
|
) || null;
|
||||||
|
return purchase;
|
||||||
|
})
|
||||||
|
.filter((purchase: Purchase) =>
|
||||||
|
['PayFromWallet', 'CancelPayFromWallet', 'RefillWallet'].includes(
|
||||||
|
purchase.transactionType
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.purchasesShortArray = this.purchases.slice(0, this.lastViewOrder);
|
||||||
this.ordersLoadingStatus = false;
|
this.ordersLoadingStatus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,4 +106,10 @@ export class OrdersComponent implements OnInit {
|
|||||||
this.lastViewOrder += 4;
|
this.lastViewOrder += 4;
|
||||||
this.purchasesShortArray = this.purchases.slice(0, this.lastViewOrder);
|
this.purchasesShortArray = this.purchases.slice(0, this.lastViewOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showPurchaseInfo(purchaseInfo: PurchaseInfo) {
|
||||||
|
const dialogRef = this.dialog.open(PurchaseInfoComponent, {
|
||||||
|
data: {purchaseInfo},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,10 @@ export class WpJsonService {
|
|||||||
return this._request(`trans/${systemId}/${token}/`, 'GET', null, false, url)
|
return this._request(`trans/${systemId}/${token}/`, 'GET', null, false, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTransactionsInfo(systemId: string, token: string, url: string, delta: number): Observable<any> {
|
||||||
|
return this._request(`purchase/${systemId}/${token}/`, 'GET', null, false, url)
|
||||||
|
}
|
||||||
|
|
||||||
getSiteConfig(): Observable<any> {
|
getSiteConfig(): Observable<any> {
|
||||||
return this._request(`/assets/site-config.json`, 'GET', null, false)
|
return this._request(`/assets/site-config.json`, 'GET', null, false)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user