From 1982ce679015790b19f7019731eafb9654364933 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 8 Sep 2017 11:54:34 +0100 Subject: [PATCH] Added Org submission API and transaction fixes --- src/app/dashboard/add-data.component.html | 2 +- src/app/dashboard/add-data.component.ts | 8 +++---- src/app/providers/api-service.ts | 26 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 843acf0..4b81270 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -69,7 +69,7 @@
diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index a78f160..a7a7037 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -158,7 +158,7 @@ export class AddDataComponent { } transactionFormValidate() { - if( this.submitOrg.name.length == 0 || + if( this.submitOrg.name.length == 0 && this.amount == 0 ) { this.transactionFormInvalid = true; }else{ @@ -252,7 +252,7 @@ export class AddDataComponent { console.log(this.payrollForm.value); this.api - .login(this.payrollForm.value) + .orgPayroll(this.payrollForm.value) .subscribe( result => { console.log('data submitted!'); @@ -271,7 +271,7 @@ export class AddDataComponent { console.log(this.singleSupplierForm.value); this.api - .login(this.singleSupplierForm.value) + .orgSupplier(this.singleSupplierForm.value) .subscribe( result => { console.log('data submitted!'); @@ -290,7 +290,7 @@ export class AddDataComponent { console.log(this.employeeForm.value); this.api - .login(this.employeeForm.value) + .orgEmployee(this.employeeForm.value) .subscribe( result => { console.log('data submitted!'); diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index ee131d0..35b2369 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -130,6 +130,32 @@ export class ApiService { ).map( response => response.json() ) } + // handles Org data added + + public orgPayroll(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/org/payroll', + data + ).map( response => response.json() ) + } + + public orgSupplier(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/org/supplier', + data + ).map( response => response.json() ) + } + + public orgEmployee(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/org/employee', + data + ).map( response => response.json() ) + } + // Handles user data interaction // Checks for login status