2022-08-26 17:36:15 +00:00
|
|
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
|
|
|
import { UntypedFormBuilder, Validators, UntypedFormGroup } from '@angular/forms';
|
2022-01-22 13:49:22 +00:00
|
|
|
import { MatDialog, MatDialogConfig} from '@angular/material/dialog';
|
|
|
|
import { ProgressBarMode } from '@angular/material/progress-bar';
|
|
|
|
import { Router } from '@angular/router';
|
2022-01-19 20:50:00 +00:00
|
|
|
import { Observable } from 'rxjs';
|
2022-01-22 13:49:22 +00:00
|
|
|
import { MatStepper } from '@angular/material/stepper';
|
2022-01-28 20:03:35 +00:00
|
|
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
|
2022-01-19 20:50:00 +00:00
|
|
|
import { Country } from '../country.model';
|
2022-01-18 22:40:50 +00:00
|
|
|
import { Owner } from '../owner.model';
|
2022-01-22 13:49:22 +00:00
|
|
|
import { User } from '../user.model';
|
2022-01-18 22:40:50 +00:00
|
|
|
import { UserService } from '../user.service';
|
2022-01-22 13:49:22 +00:00
|
|
|
import { FullnodeService } from '../fullnode.service';
|
|
|
|
import { ScanComponent } from '../scan/scan.component';
|
2022-01-28 20:03:35 +00:00
|
|
|
import { TermsComponent } from '../terms/terms.component';
|
2022-01-18 22:40:50 +00:00
|
|
|
|
2023-02-14 03:39:11 +00:00
|
|
|
import { LanguageService } from '../language.service';
|
|
|
|
|
2022-01-18 22:40:50 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'app-business',
|
|
|
|
templateUrl: './business.component.html',
|
|
|
|
styleUrls: ['./business.component.css']
|
|
|
|
})
|
|
|
|
export class BusinessComponent implements OnInit {
|
|
|
|
|
2022-01-22 13:49:22 +00:00
|
|
|
@ViewChild('stepper', { static: false}) stepper: MatStepper|undefined;
|
2022-02-01 18:04:16 +00:00
|
|
|
intervalHolder: any;
|
2022-01-22 13:49:22 +00:00
|
|
|
nodeAddress: string = '';
|
2022-08-26 17:36:15 +00:00
|
|
|
zecPrice: number = 1;
|
2022-01-22 13:49:22 +00:00
|
|
|
tickets = [
|
|
|
|
{
|
2022-08-26 17:36:15 +00:00
|
|
|
value: 1,
|
|
|
|
viewValue: '1 day: USD $1'
|
2022-01-22 13:49:22 +00:00
|
|
|
},{
|
2022-08-26 17:36:15 +00:00
|
|
|
value: 6,
|
|
|
|
viewValue: '1 week: USD $6'
|
2022-01-22 13:49:22 +00:00
|
|
|
},{
|
2022-08-26 17:36:15 +00:00
|
|
|
value: 22,
|
|
|
|
viewValue: '1 month: USD $22'
|
|
|
|
},{
|
|
|
|
value: 30,
|
|
|
|
viewValue: '1 month Pro: USD $30'
|
2022-01-22 13:49:22 +00:00
|
|
|
}
|
|
|
|
];
|
2022-07-13 12:20:47 +00:00
|
|
|
bizForm: UntypedFormGroup;
|
|
|
|
payForm: UntypedFormGroup;
|
2022-01-22 13:49:22 +00:00
|
|
|
barMessage = 'Awaiting for transaction';
|
|
|
|
barMode: ProgressBarMode = 'indeterminate';
|
|
|
|
barValue = 0;
|
2022-01-19 20:50:00 +00:00
|
|
|
countries: Country[] = [];
|
2022-01-22 13:49:22 +00:00
|
|
|
owner: Owner = {
|
|
|
|
address: '',
|
2023-05-09 16:16:09 +00:00
|
|
|
name: '',
|
2022-01-22 13:49:22 +00:00
|
|
|
currency: 'usd',
|
|
|
|
tax: false,
|
|
|
|
taxValue: 0,
|
|
|
|
vat: false,
|
|
|
|
vatValue: 0,
|
|
|
|
paid: false,
|
2022-05-18 20:51:39 +00:00
|
|
|
zats: false,
|
|
|
|
invoices: false,
|
2022-07-14 16:11:04 +00:00
|
|
|
expiration: new Date(Date.now()).toISOString(),
|
2022-07-18 20:29:27 +00:00
|
|
|
payconf: false,
|
2022-08-31 13:56:06 +00:00
|
|
|
crmToken: ''
|
2022-01-22 13:49:22 +00:00
|
|
|
}
|
2022-01-19 20:50:00 +00:00
|
|
|
public countriesUpdate: Observable<Country[]>;
|
2022-01-22 13:49:22 +00:00
|
|
|
public ownerUpdate: Observable<Owner>;
|
|
|
|
public addrUpdate: Observable<string>;
|
|
|
|
public userUpdate: Observable<User>;
|
2022-08-26 17:36:15 +00:00
|
|
|
public priceUpdate: Observable<number>;
|
2022-01-22 13:49:22 +00:00
|
|
|
sessionId = '';
|
|
|
|
ownerKnown = false;
|
2022-01-28 20:03:35 +00:00
|
|
|
termsChecked = false;
|
2023-05-09 16:16:09 +00:00
|
|
|
ownerdata = {
|
|
|
|
first: '',
|
|
|
|
last: '',
|
|
|
|
phone: '',
|
|
|
|
name: '',
|
|
|
|
street: '',
|
|
|
|
city: '',
|
|
|
|
state: '',
|
|
|
|
postal: '',
|
|
|
|
country: '',
|
|
|
|
email: '',
|
|
|
|
website: ''
|
|
|
|
};
|
2023-02-14 03:39:11 +00:00
|
|
|
// -------------------------------------
|
|
|
|
//
|
|
|
|
// Language Support
|
|
|
|
//
|
2023-05-09 16:16:09 +00:00
|
|
|
vE = {
|
|
|
|
businessSignupTitle : '',
|
|
|
|
businessBizInfo : '',
|
|
|
|
businessAddrsNobiz : '',
|
|
|
|
businessBizNamelbl : '',
|
|
|
|
businessBizNameholder : '',
|
|
|
|
businessContactFnamelbl : '',
|
|
|
|
businessContactFnholder : '',
|
|
|
|
businessContactLnamelbl : '',
|
|
|
|
businessContactLnholder : '',
|
|
|
|
businessBizAddresslbl : '',
|
|
|
|
businessBizAddressholder : '',
|
|
|
|
businessBizCitylbl : '',
|
|
|
|
businessBizCityholder : '',
|
|
|
|
businessBizStatelbl : '',
|
|
|
|
businessBizStateholder : '',
|
|
|
|
businessBizPcodelbl : '',
|
|
|
|
businessBizPcodeholder : '',
|
|
|
|
businessBizCountrylbl : '',
|
|
|
|
businessBizCountryholder : '',
|
|
|
|
businessBizMaillbl : '',
|
|
|
|
businessBizMailholder : '',
|
|
|
|
businessBizWebsitelbl : '',
|
|
|
|
businessBizWebsiteholder : '',
|
|
|
|
businessAcceptTerms : '',
|
|
|
|
businessTermsOfuse : '',
|
|
|
|
businessSaveBtn : '',
|
|
|
|
businessSessionLengthlbl : '',
|
|
|
|
businessSelectSession : '',
|
|
|
|
businessSessionLabel : '',
|
|
|
|
businessSessionPaylbl : '',
|
|
|
|
businessZGoConfirmlbl : ''
|
2022-01-18 22:40:50 +00:00
|
|
|
|
2023-05-09 16:16:09 +00:00
|
|
|
};
|
|
|
|
//
|
2023-02-14 03:39:11 +00:00
|
|
|
//
|
2022-01-18 22:40:50 +00:00
|
|
|
constructor(
|
2023-02-14 03:39:11 +00:00
|
|
|
private languageService : LanguageService,
|
2022-07-13 12:20:47 +00:00
|
|
|
private fb: UntypedFormBuilder,
|
2022-01-22 13:49:22 +00:00
|
|
|
private userService: UserService,
|
|
|
|
private fullnodeService: FullnodeService,
|
|
|
|
private dialog: MatDialog,
|
|
|
|
private router: Router
|
2022-01-18 22:40:50 +00:00
|
|
|
) {
|
2022-08-26 17:36:15 +00:00
|
|
|
this.priceUpdate = fullnodeService.priceUpdate;
|
|
|
|
this.priceUpdate.subscribe(priceInfo => {
|
|
|
|
this.zecPrice = priceInfo;
|
|
|
|
});
|
2022-01-19 20:50:00 +00:00
|
|
|
this.countriesUpdate = userService.countriesUpdate;
|
2022-01-22 13:49:22 +00:00
|
|
|
this.ownerUpdate = userService.ownerUpdate;
|
|
|
|
this.userUpdate = userService.userUpdate;
|
|
|
|
this.userUpdate.subscribe(userInfo => {
|
|
|
|
this.sessionId = userInfo.session;
|
|
|
|
});
|
|
|
|
this.addrUpdate = fullnodeService.addrUpdate;
|
|
|
|
this.addrUpdate.subscribe(nodeAdd => {
|
|
|
|
this.nodeAddress = nodeAdd;
|
|
|
|
});
|
2022-01-18 22:40:50 +00:00
|
|
|
this.bizForm = fb.group({
|
2022-01-19 20:50:00 +00:00
|
|
|
name: ['', Validators.required],
|
2022-01-28 20:03:35 +00:00
|
|
|
first: ['', Validators.required],
|
|
|
|
last: ['', Validators.required],
|
2022-01-19 20:50:00 +00:00
|
|
|
street: ['', Validators.required],
|
|
|
|
city: ['', Validators.required],
|
|
|
|
state: ['', Validators.required],
|
|
|
|
postal: ['', Validators.required],
|
|
|
|
country: ['', Validators.required],
|
2022-01-22 13:49:22 +00:00
|
|
|
email: ['', [Validators.email, Validators.required]],
|
2022-01-28 20:03:35 +00:00
|
|
|
website: [''],
|
|
|
|
terms: [false]
|
2022-01-22 13:49:22 +00:00
|
|
|
});
|
|
|
|
this.payForm= fb.group({
|
|
|
|
session: ['', Validators.required]
|
2022-01-19 20:50:00 +00:00
|
|
|
});
|
|
|
|
this.userService.getCountries();
|
|
|
|
this.countriesUpdate.subscribe((countries) => {
|
|
|
|
this.countries = countries;
|
2022-01-18 22:40:50 +00:00
|
|
|
});
|
2022-01-22 13:49:22 +00:00
|
|
|
this.ownerUpdate.subscribe((owner) => {
|
|
|
|
this.owner = owner;
|
|
|
|
});
|
2022-01-18 22:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
2023-02-14 03:39:11 +00:00
|
|
|
this.chgUILanguage();
|
2022-02-01 18:04:16 +00:00
|
|
|
this.intervalHolder = setInterval(() => {
|
|
|
|
this.loginCheck();
|
|
|
|
}, 1000 * 60);
|
2022-01-18 22:40:50 +00:00
|
|
|
}
|
|
|
|
|
2022-01-22 13:49:22 +00:00
|
|
|
ngAfterViewInit(): void {
|
|
|
|
this.ownerUpdate.subscribe(ownerData => {
|
|
|
|
if(ownerData.name.length > 0 && this.stepper!.selectedIndex == 0){
|
|
|
|
this.stepper!.next();
|
2022-07-14 16:11:04 +00:00
|
|
|
this.loginCheck();
|
2022-01-22 13:49:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-28 20:03:35 +00:00
|
|
|
onChange(ob: MatSlideToggleChange){
|
2023-05-08 18:45:34 +00:00
|
|
|
//console.log(ob.checked);
|
2022-01-28 20:03:35 +00:00
|
|
|
this.termsChecked = ob.checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTerms() {
|
|
|
|
const dialogConfig = new MatDialogConfig();
|
|
|
|
dialogConfig.disableClose = true;
|
|
|
|
dialogConfig.autoFocus = true;
|
|
|
|
|
2023-05-08 18:45:34 +00:00
|
|
|
this.dialog.open(TermsComponent, dialogConfig);
|
|
|
|
//dialogRef.afterClosed().subscribe(val => {
|
|
|
|
//console.log('Terms read');
|
|
|
|
//});
|
2022-01-28 20:03:35 +00:00
|
|
|
}
|
|
|
|
|
2022-01-22 13:49:22 +00:00
|
|
|
save() {
|
2023-05-09 16:16:09 +00:00
|
|
|
this.ownerdata = {
|
2022-02-01 18:04:16 +00:00
|
|
|
first: this.bizForm.get('first')!.value,
|
|
|
|
last: this.bizForm.get('last')!.value,
|
2022-01-22 13:49:22 +00:00
|
|
|
phone: '',
|
|
|
|
name: this.bizForm.get('name')!.value,
|
|
|
|
street: this.bizForm.get('street')!.value,
|
|
|
|
city: this.bizForm.get('city')!.value,
|
|
|
|
state: this.bizForm.get('state')!.value,
|
|
|
|
postal: this.bizForm.get('postal')!.value,
|
|
|
|
country: this.bizForm.get('country')!.value,
|
|
|
|
email: this.bizForm.get('email')!.value,
|
2023-05-09 16:16:09 +00:00
|
|
|
website: this.bizForm.get('website')!.value
|
2022-01-22 13:49:22 +00:00
|
|
|
};
|
2023-05-09 16:16:09 +00:00
|
|
|
this.userService.addOwner(this.ownerdata);
|
2022-01-22 13:49:22 +00:00
|
|
|
this.stepper!.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
pay(){
|
|
|
|
const dialogConfig = new MatDialogConfig();
|
|
|
|
|
|
|
|
dialogConfig.disableClose = true;
|
|
|
|
dialogConfig.autoFocus = true;
|
|
|
|
dialogConfig.data = {
|
2022-08-26 17:36:15 +00:00
|
|
|
totalZec: (this.payForm.get('session')!.value)/this.zecPrice,
|
2022-01-22 13:49:22 +00:00
|
|
|
addr: this.nodeAddress,
|
|
|
|
session: this.sessionId,
|
|
|
|
pay: true
|
|
|
|
};
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(ScanComponent, dialogConfig);
|
|
|
|
dialogRef.afterClosed().subscribe(val => {
|
2023-05-08 18:45:34 +00:00
|
|
|
//console.log('Awaiting payment');
|
2022-01-22 13:49:22 +00:00
|
|
|
if(val){
|
|
|
|
this.stepper!.next();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-02-01 18:04:16 +00:00
|
|
|
loginCheck(){
|
2022-02-02 18:26:58 +00:00
|
|
|
this.userService.findUser();
|
2022-02-01 18:04:16 +00:00
|
|
|
this.ownerUpdate.subscribe((owner) => {
|
|
|
|
if(owner.paid) {
|
2022-07-26 16:26:42 +00:00
|
|
|
clearInterval(this.intervalHolder);
|
2022-02-01 18:04:16 +00:00
|
|
|
this.router.navigate(['/shop']);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-02-14 03:39:11 +00:00
|
|
|
chgUILanguage(){
|
2023-05-08 18:45:34 +00:00
|
|
|
//console.log('BUSINESS.chgUILanguage Called ');
|
|
|
|
this.languageService.getViewElements('business').subscribe(
|
|
|
|
response => {
|
|
|
|
//console.log('Received >> ', response );
|
|
|
|
//console.log('Language Code : ', response.language);
|
|
|
|
//console.log('Component Name : ',response.component);
|
|
|
|
//console.log('Language data : ',response.data);
|
2023-02-14 03:39:11 +00:00
|
|
|
|
2023-05-08 18:45:34 +00:00
|
|
|
this.vE.businessSignupTitle = response.data.business_signup_title;
|
|
|
|
this.vE.businessBizInfo = response.data.business_biz_info;
|
|
|
|
this.vE.businessAddrsNobiz = response.data.business_addrs_nobiz;
|
|
|
|
this.vE.businessBizNamelbl = response.data.business_biz_namelbl;
|
|
|
|
this.vE.businessBizNameholder = response.data.business_biz_nameholder;
|
|
|
|
this.vE.businessContactFnamelbl = response.data.business_contact_fnamelbl;
|
|
|
|
this.vE.businessContactFnholder = response.data.business_contact_fnholder;
|
|
|
|
this.vE.businessContactLnamelbl = response.data.business_contact_lnamelbl;
|
|
|
|
this.vE.businessBizAddresslbl = response.data.business_biz_addresslbl;
|
|
|
|
this.vE.businessBizAddressholder = response.data.business_biz_addressholder;
|
|
|
|
this.vE.businessBizCitylbl = response.data.business_biz_citylbl;
|
|
|
|
this.vE.businessBizCityholder = response.data.business_biz_cityholder;
|
|
|
|
this.vE.businessBizStatelbl = response.data.business_biz_statelbl;
|
|
|
|
this.vE.businessBizStateholder = response.data.business_biz_stateholder;
|
|
|
|
this.vE.businessBizPcodelbl = response.data.business_biz_pcodelbl;
|
|
|
|
this.vE.businessBizPcodeholder = response.data.business_biz_pcodeholder;
|
|
|
|
this.vE.businessBizCitylbl = response.data.business_biz_citylbl;
|
|
|
|
this.vE.businessBizCityholder = response.data.business_biz_cityholder;
|
|
|
|
this.vE.businessBizCountrylbl = response.data.business_biz_countrylbl;
|
|
|
|
this.vE.businessBizCountryholder = response.data.business_biz_countryholder;
|
|
|
|
this.vE.businessBizMaillbl = response.data.business_biz_maillbl;
|
|
|
|
this.vE.businessBizMailholder = response.data.business_biz_mailholder;
|
|
|
|
this.vE.businessBizWebsitelbl = response.data.business_biz_websitelbl;
|
|
|
|
this.vE.businessBizWebsiteholder = response.data.business_biz_websiteholder;
|
|
|
|
this.vE.businessAcceptTerms = response.data.business_accept_terms;
|
|
|
|
this.vE.businessTermsOfuse = response.data.business_terms_ofuse;
|
|
|
|
this.vE.businessSaveBtn = response.data.business_save_btn;
|
|
|
|
this.vE.businessSessionLengthlbl = response.data.business_session_lengthlbl;
|
|
|
|
this.vE.businessSelectSession = response.data.business_select_session;
|
|
|
|
this.vE.businessSessionLabel = response.data.business_session_label;
|
|
|
|
this.vE.businessSessionPaylbl = response.data.business_session_paylbl;
|
|
|
|
this.vE.businessZGoConfirmlbl = response.data.business_zgo_confirmlbl;
|
2023-02-14 03:39:11 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
error => { console.log('Error >> ',error); }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-18 22:40:50 +00:00
|
|
|
}
|