From 22858a2f4928b26664692c97462595597d4f55ba Mon Sep 17 00:00:00 2001 From: gofnnp Date: Thu, 1 Jun 2023 10:28:38 +0400 Subject: [PATCH] =?UTF-8?q?dev=20#14294=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B5=20=D0=B8=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B0=D0=BB=D0=B0=20'=D0=BC=D0=B5=D0=B6?= =?UTF-8?q?=D0=B4=D1=83'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/account/orders/orders.component.ts | 34 +++++++++++++++---- angular/src/app/services/wp-json.service.ts | 4 +++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/angular/src/app/pages/account/orders/orders.component.ts b/angular/src/app/pages/account/orders/orders.component.ts index 8121c87..6d99d5f 100644 --- a/angular/src/app/pages/account/orders/orders.component.ts +++ b/angular/src/app/pages/account/orders/orders.component.ts @@ -73,12 +73,34 @@ export class OrdersComponent implements OnInit { this.lastViewOrder = 3; switch (dateFilter.filterType) { case 'between': - this.filteredOfDatePurchases = this.purchases.filter((value) => { - return moment(value.transactionCreateDate).isBetween( - dateFilter.from, - moment(dateFilter.to).add(1, 'day') - ); - }); + this.ordersLoadingStatus = true; + this.filteredOfDatePurchases = [] + const token = this.cookiesService.getItem('token') + this.wpJsonService.getTransactionsBetween(environment.systemId, token || '', environment.icardProxy, { + date_from: dateFilter.from?.toLocaleString() || '', + date_to: dateFilter.to?.toLocaleString() || '' + }).subscribe({ + next: (value) => { + this.filteredOfDatePurchases = Object.values(value)[0] as Purchase[] + this.ordersLoadingStatus = false + this.purchasesShortArray = this.filteredOfDatePurchases.slice( + 0, + this.lastViewOrder + ); + console.log(value); + + }, + error: (err) => { + console.error(err); + + } + }) + // this.filteredOfDatePurchases = this.purchases.filter((value) => { + // return moment(value.transactionCreateDate).isBetween( + // dateFilter.from, + // moment(dateFilter.to).add(1, 'day') + // ); + // }); break; case 'currentMonth': diff --git a/angular/src/app/services/wp-json.service.ts b/angular/src/app/services/wp-json.service.ts index 68fb9fb..4540729 100644 --- a/angular/src/app/services/wp-json.service.ts +++ b/angular/src/app/services/wp-json.service.ts @@ -58,6 +58,10 @@ export class WpJsonService { return this._request(`trans/${systemId}/${token}/`, 'GET', null, false, url) } + getTransactionsBetween(systemId: string, token: string, url: string, body: {date_from: string, date_to: string}): Observable { + return this._request(`trans/${systemId}/${token}/`, 'POST', body, false, url) + } + getTransactionsInfo(systemId: string, token: string, url: string, delta: number): Observable { return this._request(`purchase/${systemId}/${token}/`, 'GET', null, false, url) }