Services correction for new owner data structure

This commit is contained in:
Rene Vergara 2023-05-15 09:48:57 -05:00
parent 2c04145a43
commit d284a736f6
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
16 changed files with 49 additions and 23 deletions

View File

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

View File

@ -38,7 +38,8 @@ export class DbExportComponent implements OnInit {
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
crmToken: ''
crmToken: '',
viewkey: ''
};
_ordersOk = false;

View File

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

View File

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

View File

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

View File

@ -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 = '';

View File

@ -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();

View File

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

View File

@ -13,4 +13,5 @@ export interface Owner {
expiration: string;
payconf: boolean;
crmToken: string;
viewkey: string;
}

View File

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

View File

@ -29,7 +29,8 @@ export class ReceiptService {
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
crmToken: ''
crmToken: '',
viewkey: ''
},
order: {
address: '',

View File

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

View File

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

View File

@ -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();
}

View File

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

View File

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