From 40462b7d8fc73609cf21ac3d88626bc85dc5e793 Mon Sep 17 00:00:00 2001 From: Finn Date: Fri, 12 Jul 2019 18:50:59 +0100 Subject: [PATCH] Added proper supplier table --- src/app/dashboard/dashboard.module.ts | 2 + src/app/dashboard/suppliers.component.html | 38 ++++++++++--------- src/app/dashboard/suppliers.component.ts | 24 ++++++++++++ .../dashboard/transaction-log.component.ts | 10 ++--- src/app/providers/api-service.ts | 5 ++- src/app/shared/supplier-result.component.html | 3 ++ src/app/shared/supplier-result.component.ts | 19 ++++++++++ 7 files changed, 77 insertions(+), 24 deletions(-) create mode 100644 src/app/shared/supplier-result.component.html create mode 100644 src/app/shared/supplier-result.component.ts diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index b35c99c..7e006b3 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -37,6 +37,7 @@ import { OrgTableComponent } from '../shared/org-table.component'; import { RecurResultComponent } from '../shared/recur-result.component'; import { RecurTableComponent } from '../shared/recur-table.component'; import { TransactionResultComponent } from '../shared/transaction-result.component'; +import { SupplierResultComponent } from '../shared/supplier-result.component'; import { PayrollResultComponent } from '../shared/payroll-result.component'; import { LeaderboardResultComponent } from '../shared/leaderboard-result.component'; @@ -71,6 +72,7 @@ import { environment } from '../../environments/environment'; TransactionLogComponent, CategoryMonthComponent, TransactionResultComponent, + SupplierResultComponent, PayrollLogComponent, PayrollResultComponent, LeaderboardComponent, diff --git a/src/app/dashboard/suppliers.component.html b/src/app/dashboard/suppliers.component.html index fcf79dd..ab8b3f6 100644 --- a/src/app/dashboard/suppliers.component.html +++ b/src/app/dashboard/suppliers.component.html @@ -10,24 +10,28 @@ - - - - Tom's Tippity Top Toenails Ltd. - LA11LY - £250,000.00 - - - Selena's Scratching Sticks Inc. - WS15PQ - £5.00 - - - Big Barry and Son's Balloon Store and Clown Outfits Corp. - PF43RD - £22.00 - + + + + diff --git a/src/app/dashboard/suppliers.component.ts b/src/app/dashboard/suppliers.component.ts index fce8483..4885cb5 100644 --- a/src/app/dashboard/suppliers.component.ts +++ b/src/app/dashboard/suppliers.component.ts @@ -16,6 +16,15 @@ export class SuppliersComponent implements OnInit, AfterViewInit { @Output() public onClick = new EventEmitter(); @Input() public categories: any; + supplierList: any; + supplierListAvailable = false; + + public paginateConfig: PaginationInstance = { + id: 'transpaginate', + itemsPerPage: 10, + currentPage: 1, + totalItems: 0 + }; public recurClick(event: any): void { this.onClick.emit( event ); @@ -26,7 +35,22 @@ export class SuppliersComponent implements OnInit, AfterViewInit { ) { } ngOnInit(): void { + this.loadSuppliers(1); + } + loadSuppliers(logPage: number) { + this.api.externalSuppliers(logPage).subscribe( + result => { + this.supplierList = result.suppliers; + this.paginateConfig.totalItems = result.page_no; + this.paginateConfig.currentPage = logPage; + this.noTransactionList = false; + }, + error => { + console.log('Retrieval Error'); + console.log( error._body ); + } + ); } ngAfterViewInit() { diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index fcd290c..0e04ad5 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -31,11 +31,11 @@ export class TransactionLogComponent implements OnInit { updatedTime: string; public paginateConfig: PaginationInstance = { - id: 'transpaginate', - itemsPerPage: 10, - currentPage: 1, - totalItems: 0 - }; + id: 'transpaginate', + itemsPerPage: 10, + currentPage: 1, + totalItems: 0 + }; constructor( private api: ApiService, diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 52fd12b..7d3f00e 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -144,12 +144,13 @@ export class ApiService { ); } - public externalSuppliers() { + public externalSuppliers(data) { const key = this.sessionKey; return this.http.post( - this.apiUrl + '/organisation/external/suppliers', + this.apiUrl + '/v1/organisation/external/suppliers', { session_key : key, + page : data } ); } diff --git a/src/app/shared/supplier-result.component.html b/src/app/shared/supplier-result.component.html new file mode 100644 index 0000000..5f73644 --- /dev/null +++ b/src/app/shared/supplier-result.component.html @@ -0,0 +1,3 @@ +{{supplier.name}} +{{supplier.postcode}} +{{supplier.spend | currency:'GBP':'symbol':'1.2-2' }} diff --git a/src/app/shared/supplier-result.component.ts b/src/app/shared/supplier-result.component.ts new file mode 100644 index 0000000..83ffc4c --- /dev/null +++ b/src/app/shared/supplier-result.component.ts @@ -0,0 +1,19 @@ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; + +interface SupplierData { + name: string; + postcode: string; + spend: number = 0; +} + +@Component({ + // tslint:disable-next-line + selector: '[supplier-result]', + templateUrl: 'supplier-result.component.html', +}) +export class SupplierResultComponent implements OnInit { + @Input() public supplier: SupplierData; + + ngOnInit(): void { + } +}