Services correction for new owner data structure
This commit is contained in:
parent
2c04145a43
commit
d284a736f6
16 changed files with 49 additions and 23 deletions
|
@ -61,7 +61,8 @@ export class BusinessComponent implements OnInit {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
}
|
||||
public countriesUpdate: Observable<Country[]>;
|
||||
public ownerUpdate: Observable<Owner>;
|
||||
|
|
|
@ -38,7 +38,8 @@ export class DbExportComponent implements OnInit {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
|
||||
_ordersOk = false;
|
||||
|
|
|
@ -39,7 +39,8 @@ export class FullnodeService{
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
|
||||
constructor(private http: HttpClient, public userService: UserService){
|
||||
|
|
|
@ -33,7 +33,8 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
public heightUpdate: Observable<number>;
|
||||
public ownerUpdate: Observable<Owner>;
|
||||
|
|
|
@ -46,7 +46,8 @@ export class ItemListComponent implements OnInit{
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
|
||||
public ownerUpdate: Observable<Owner>;
|
||||
|
|
|
@ -59,7 +59,8 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
zecPrice: number = 1;
|
||||
nodeAddress: string = '';
|
||||
|
|
|
@ -48,7 +48,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
private FullnodeSub: Subscription = new Subscription();
|
||||
private UserSub: Subscription = new Subscription();
|
||||
|
|
|
@ -40,7 +40,8 @@ export class OrderService {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
},
|
||||
order: {
|
||||
address: '',
|
||||
|
@ -207,7 +208,7 @@ export class OrderService {
|
|||
});
|
||||
this.dataStore.order.closed = true;
|
||||
this.dataStore.order.paid = paid;
|
||||
let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders });
|
||||
let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders, params: this.reqParams });
|
||||
obs.subscribe((orderData) => {
|
||||
console.log('Closed order', orderData);
|
||||
this.dataStore.order = {
|
||||
|
|
|
@ -13,4 +13,5 @@ export interface Owner {
|
|||
expiration: string;
|
||||
payconf: boolean;
|
||||
crmToken: string;
|
||||
viewkey: string;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ export class PmtserviceComponent implements OnInit {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
|
||||
public order: Order = {
|
||||
|
|
|
@ -29,7 +29,8 @@ export class ReceiptService {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
},
|
||||
order: {
|
||||
address: '',
|
||||
|
|
|
@ -127,7 +127,7 @@ export class SettingsComponent implements OnInit {
|
|||
public xeroService: XeroService,
|
||||
public wooService: WoocommerceService,
|
||||
private dialogRef: MatDialogRef<SettingsComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: {o: Owner, v: string}) {
|
||||
@Inject(MAT_DIALOG_DATA) public data: {o: Owner}) {
|
||||
this.useZats = data.o.zats;
|
||||
this.useVKey = data.o.payconf;
|
||||
this.settingsForm = fb.group({
|
||||
|
@ -136,7 +136,7 @@ export class SettingsComponent implements OnInit {
|
|||
useZats: [data.o.zats, Validators.required],
|
||||
useVKey: [data.o.payconf, Validators.required],
|
||||
// proVersion: [data.invoices, Validators.required],
|
||||
vKey: [data.v]
|
||||
vKey: [data.o.viewkey]
|
||||
});
|
||||
this.accCodForm = fb.group ({
|
||||
xAcc: [this.xeroAccCod]
|
||||
|
@ -146,7 +146,7 @@ export class SettingsComponent implements OnInit {
|
|||
this.settingsForm.get('vKey')!.enable();
|
||||
}
|
||||
this.owner = data.o;
|
||||
this.viewkey = data.v;
|
||||
this.viewkey = data.o.viewkey;
|
||||
this.proVersion = this.owner.invoices;
|
||||
if ( this.owner.crmToken !== '' ) {
|
||||
this.linked2Xero = true;
|
||||
|
|
|
@ -38,7 +38,8 @@ export class UserService{
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
},
|
||||
countries: []
|
||||
};
|
||||
|
@ -140,7 +141,7 @@ export class UserService{
|
|||
return obs;
|
||||
}
|
||||
|
||||
addOwner(oData: {first: string, last: string, phone: string, name: string, street: string, city: string, state: string, postal: string, country: string, email: string, website: string, payconf: boolean}) {
|
||||
addOwner(oData: {first: string, last: string, phone: string, name: string, street: string, city: string, state: string, postal: string, country: string, email: string, website: string}) {
|
||||
|
||||
let obs = this.http.post(this.beUrl+'api/owner', {payload: oData}, {headers: this.reqHeaders, params: this.reqParams});
|
||||
|
||||
|
@ -152,7 +153,7 @@ export class UserService{
|
|||
error: (error) => {
|
||||
//console.log("Status is : [" + error.status + "]");
|
||||
if ( error.status = 500 ) {
|
||||
this.notifierService .showNotification("Invalid Viewing Key, changes not saved!!","Close",'error');
|
||||
this.notifierService.showNotification("Invalid Viewing Key, changes not saved!!","Close",'error');
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -160,6 +161,20 @@ export class UserService{
|
|||
return obs;
|
||||
}
|
||||
|
||||
saveOwnerSettings(o: Owner) {
|
||||
let obs = this.http.post(this.beUrl + 'api/ownersettings', {payload: o}, {headers: this.reqHeaders, params: this.reqParams});
|
||||
obs.subscribe({
|
||||
next: () => {
|
||||
this.getOwner();
|
||||
},
|
||||
error: (error) => {
|
||||
if ( error.status == 500 ){
|
||||
this.notifierService.showNotification("Saving settings failed", "Close", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getOwner() {
|
||||
//console.log('getOwner', address);
|
||||
//const ownParams = this.reqParams.append('address', address)
|
||||
|
|
|
@ -41,7 +41,8 @@ export class ViewerComponent implements OnInit {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
public price: number = 1;
|
||||
public addrUpdate: Observable<string>;
|
||||
|
@ -114,13 +115,13 @@ export class ViewerComponent implements OnInit {
|
|||
|
||||
dialogConfig.disableClose = true;
|
||||
dialogConfig.autoFocus = true;
|
||||
dialogConfig.data = {o: this.owner, v: ''};
|
||||
dialogConfig.data = {o: this.owner};
|
||||
|
||||
const dialogRef = this.dialog.open(SettingsComponent, dialogConfig);
|
||||
dialogRef.afterClosed().subscribe((val) => {
|
||||
if (val != null) {
|
||||
//console.log('Saving settings', val);
|
||||
//this.userService.addOwner(val);
|
||||
this.userService.saveOwnerSettings(val);
|
||||
this.fullnodeService.getPrice(val.currency);
|
||||
this.loginCheck();
|
||||
}
|
||||
|
|
|
@ -56,9 +56,7 @@ export class XeroService {
|
|||
obs.subscribe(xeroDataResponse => {
|
||||
if (xeroDataResponse.status == 200) {
|
||||
this.clientId = xeroDataResponse.body!.xeroConfig.clientId;
|
||||
//this.clientSecret = xeroDataResponse.body!.xeroConfig.clientSecret;
|
||||
this._clientIdUpdated.next(Object.assign({}, this).clientId);
|
||||
//this._clientSecretUpdated.next(Object.assign({}, this).clientSecret);
|
||||
} else {
|
||||
console.log('No config in DB!');
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ export class XeroRegComponent implements OnInit {
|
|||
invoices: false,
|
||||
expiration: new Date(Date.now()).toISOString(),
|
||||
payconf: false,
|
||||
crmToken: ''
|
||||
crmToken: '',
|
||||
viewkey: ''
|
||||
};
|
||||
public ownerUpdate:Observable<Owner>;
|
||||
public flag: boolean = false;
|
||||
|
|
Loading…
Reference in a new issue