diff --git a/ng-seed/src/app/appoinment/business/add-business/add-business.component.html b/ng-seed/src/app/appoinment/business/add-business/add-business.component.html index fb233f1..b13fa05 100644 --- a/ng-seed/src/app/appoinment/business/add-business/add-business.component.html +++ b/ng-seed/src/app/appoinment/business/add-business/add-business.component.html @@ -43,7 +43,45 @@ Address is required Limit exceed - + + + Country + + Select Country + {{ country.flag }} {{ country.name }} + Invalid option + + + + + + State + + -- Select Your State -- + {{ state.name }} + Invalid option + + + + + City + + -- Select Your City -- + {{ city.name }} + Invalid option + + + + Type Of Currency diff --git a/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts b/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts index f897d46..384b451 100644 --- a/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts +++ b/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts @@ -1,5 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Component, Inject, OnInit, Optional } from '@angular/core'; +import { ElementRef, VERSION, ViewChild } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { MatCheckboxChange } from '@angular/material/checkbox'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; @@ -7,6 +8,7 @@ import { Router } from '@angular/router'; import { NotifierService } from 'angular-notifier'; import { environment } from 'environments/environment'; import { map } from 'rxjs/internal/operators/map'; +import { Country, State, City } from 'country-state-city'; export interface UsersData { name: string; id: number; @@ -18,7 +20,17 @@ export interface UsersData { styleUrls: ['./add-business.component.scss'] }) export class AddBusinessComponent implements OnInit { + @ViewChild('country') country: ElementRef + @ViewChild('city') city: ElementRef + @ViewChild('state') state: ElementRef + name = 'Angular ' + VERSION.major; + countries = Country.getAllCountries(); + states = null; + cities = null; + selectedCountry; + selectedState; + selectedCity; form: FormGroup; fileToUpload: any; imageUrl: any; @@ -29,6 +41,7 @@ export class AddBusinessComponent implements OnInit { formData: any=[]; selectedFiles: any; currentFileUpload: any; + countryevent:any=[]; private apiUrl = environment.apiEndpoint; constructor(private http: HttpClient,private notifierService: NotifierService,private router: Router,private formBuilder: FormBuilder, public dialogRef: MatDialogRef, @@ -50,6 +63,46 @@ export class AddBusinessComponent implements OnInit { closeDialog(){ this.dialogRef.close({event:'Cancel'}); } + + onCountryChange($event): void { + console.log($event,$event.value) + this.countryevent = $event.value + this.states = State.getStatesOfCountry(JSON.parse($event.value).isoCode); + console.log(JSON.parse($event.value)) + this.form.controls['currency'].setValue(JSON.parse($event.value).currency) + + this.selectedCountry = JSON.parse($event.value); + this.cities = this.selectedState = this.selectedCity = null; + } + + onStateChange($event): void { + console.log($event,$event.value) + this.cities = City.getCitiesOfState( JSON.parse( this.countryevent).isoCode, JSON.parse($event.value).isoCode) + console.log(this.cities) + this.selectedState = JSON.parse($event.value); + this.selectedCity = null; + + } + + onCityChange($event): void { + console.log($event,$event.value) + this.selectedCity = JSON.parse($event.value) + console.log( this.selectedCity ) + } + + clear(type: string): void { + switch(type) { + case 'country': + this.selectedCountry = this.country.nativeElement.value = this.states = this.cities = this.selectedState = this.selectedCity = null; + break; + case 'state': + this.selectedState = this.state.nativeElement.value = this.cities = this.selectedCity = null; + break; + case 'city': + this.selectedCity = this.city.nativeElement.value = null; + break; + } + } onSelectFile(event) { console.log(event) console.log(event.target.files[0]) @@ -87,6 +140,12 @@ export class AddBusinessComponent implements OnInit { this.dialogRef.close(); } ngOnInit() { + let valData; + if(this.action == 'Add'){ + valData= [this.validateUsernameAvailability.bind(this)] + }else{ + valData = null + } let userrole = localStorage.getItem('user_role') this.form = new FormGroup({ admin_checked: new FormControl('',null), @@ -95,13 +154,29 @@ export class AddBusinessComponent implements OnInit { address: new FormControl('', [Validators.required, Validators.maxLength(100)]), city: new FormControl('', [Validators.required]), currency: new FormControl('',[Validators.required]), + country: new FormControl('',[Validators.required]), state: new FormControl('', [Validators.required]), email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', - ),],[this.validateUsernameAvailability.bind(this)]), + ),],valData), contactNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10)]), createdBy:new FormControl(userrole,[Validators.required]), }); + + this.countryname(JSON.parse(this.local_data.country)) + this.statename(JSON.parse(this.local_data.state)) + console.log(this.local_data) + this.local_data.country = JSON.parse(this.local_data.country).name + this.local_data.state = JSON.parse(this.local_data.state).name + this.local_data.city = JSON.parse(this.local_data.city).name + console.log(this.local_data) + this.form.patchValue(this.local_data) + setTimeout(() => { + + + this.form.patchValue(this.local_data) + }, 1500); + this.form.patchValue(this.local_data) } @@ -122,7 +197,7 @@ export class AddBusinessComponent implements OnInit { tmp.push(element.email) }); console.log(tmp,`${control.value}`); - return !tmp.includes(`${control.value}` && this.action == 'add') ? null : { usernameTaken: true }; + return !tmp.includes(`${control.value}`) ? null : { usernameTaken: true }; }) ); } @@ -149,8 +224,9 @@ export class AddBusinessComponent implements OnInit { this.formData.append('contactNo', tmp.contactNo); this.formData.append('busName', tmp.busName); this.formData.append('address', tmp.address); - this.formData.append('state', tmp.state); - this.formData.append('city', tmp.city); + this.formData.append('country', JSON.stringify(this.countryevent) ); + this.formData.append('state', JSON.stringify(this.selectedState)); + this.formData.append('city', JSON.stringify(this.selectedCity)); this.formData.append('currency',tmp.currency) console.log(this.formData) this.dialogRef.close({event:this.action,data:this.formData,admincheck:tmp.admin_checked}); @@ -162,5 +238,30 @@ export class AddBusinessComponent implements OnInit { return this.apiUrl+'imageViewer?img_name='+image; } + countryname(country){ + console.log(country) + + // console.log($event,$event.value) + this.countryevent = country + this.states = State.getStatesOfCountry(country.isoCode); + console.log(country) + this.form.controls['currency'].setValue(country.currency) + + this.selectedCountry = country; + this.cities = this.selectedState = this.selectedCity = null; + } + + statename(state){ + // console.log($event,$event.value) + this.cities = City.getCitiesOfState( this.countryevent.isoCode, state.isoCode) + console.log(this.cities) + this.selectedState = state; + this.selectedCity = null; + } + + cityname(city){ + // console.log($event,$event.value) + this.selectedCity = city + } } diff --git a/ng-seed/src/app/appoinment/business/business-list/business-list.component.html b/ng-seed/src/app/appoinment/business/business-list/business-list.component.html index e57e70b..40426ea 100644 --- a/ng-seed/src/app/appoinment/business/business-list/business-list.component.html +++ b/ng-seed/src/app/appoinment/business/business-list/business-list.component.html @@ -45,7 +45,7 @@ Address - {{row.address}},{{row.city}} , {{row.state}} + {{row.address}} diff --git a/ng-seed/src/app/appoinment/user/add-user/add-user.component.ts b/ng-seed/src/app/appoinment/user/add-user/add-user.component.ts index 5ad0a01..76474e9 100644 --- a/ng-seed/src/app/appoinment/user/add-user/add-user.component.ts +++ b/ng-seed/src/app/appoinment/user/add-user/add-user.component.ts @@ -57,6 +57,12 @@ export class AddUserComponent implements OnInit { ngOnInit() { + let valData; + if(this.action == 'Add'){ + valData= [this.validateUsernameAvailability.bind(this)] + }else{ + valData = null + } this.hide = true; this.disableBus = localStorage.getItem('go_admin') this.userrole = localStorage.getItem('user_role') @@ -69,7 +75,7 @@ export class AddUserComponent implements OnInit { // lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]), email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', - ),],[this.validateUsernameAvailability.bind(this)]), + ),],valData), // password: new FormControl('', [Validators.required, Validators.minLength(6)]), password: new FormControl('', [Validators.required,Validators.pattern( '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*_=+-]).{8,12}$' diff --git a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts index 53ad90d..7869b97 100644 --- a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts +++ b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.ts @@ -18,6 +18,7 @@ export class BookingSummaryComponent implements OnInit { summary:any= false; busName: any; logo: any; + currency:any =[]; private apiUrl = environment.apiEndpoint; customerBookingDetails: any = []; busCurrency: any = []; @@ -42,6 +43,7 @@ export class BookingSummaryComponent implements OnInit { } ngOnInit() { + this.currency = localStorage.getItem('currency') this.end_user.summmarylist_observable$.subscribe((res) => { console.log('booked2', res); this.customerBookingDetails = res[0].customer[0]