Added Org submission API and transaction fixes

This commit is contained in:
piratefinn 2017-09-08 11:54:34 +01:00
parent 65cbea5d5d
commit 1982ce6790
3 changed files with 31 additions and 5 deletions

View file

@ -69,7 +69,7 @@
</div>
</div>
<div class="card-footer">
<button type="submit" (click)="postTransaction()" [disabled]="TransactionFormInvalid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
<button type="submit" (click)="postTransaction()" [disabled]="transactionFormInvalid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div>
</div>
<div *ngIf="accountType == 'organisation'" class="card">

View file

@ -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!');

View file

@ -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