business user and login page issue fix
This commit is contained in:
parent
9571d4c816
commit
2cc34d957b
@ -21,10 +21,10 @@
|
||||
<mat-error *ngIf="!form.get('email')?.errors?.required && (form.get('email')?.errors?.pattern)">
|
||||
Please enter a valid email address
|
||||
</mat-error>
|
||||
<mat-error *ngIf="myError('email', 'required')">email is required</mat-error>
|
||||
<mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
<mat-error *ngIf="myError('email', 'required')">Email is required</mat-error>
|
||||
<!-- <mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-error> -->
|
||||
<mat-error *ngIf="form.get('email').errors?.usernameTaken && form.get('email').dirty">
|
||||
Email already exists...
|
||||
</mat-error>
|
||||
@ -117,6 +117,10 @@
|
||||
<img *ngIf="imageViewStatus == true" class="image mb-2" [src]="url" height="150" width="150"><br/>
|
||||
<input type='file'accept="image/*" data-max-size="2048" style="width: 50%;" (change)="onSelectFile($event)" formControlName="logo"><br>
|
||||
<span *ngIf="imageViewStatus != true" class="imgSizeValidation">Upload Below 2MB <br> Supported File (jpg,jpeg and png)</span>
|
||||
<!-- Add mat-error for logo -->
|
||||
<mat-error *ngIf="form.get('logo').hasError('required')">Logo is required</mat-error>
|
||||
<mat-error *ngIf="form.get('logo').hasError('maxSizeExceeded')">File size exceeds 2MB</mat-error>
|
||||
<!-- Add more error conditions if needed -->
|
||||
</div>
|
||||
<div fxFlex.xs="30" fxFlex.sm="30" fxFlex.md="30" fxFlex.lg="30" fxFlex.xl="30" fxLayoutAlign="start end">
|
||||
<mat-checkbox *ngIf="action != 'Update'" class="example-margin mt-2" formControlName="admin_checked" (change)="showOptions($event)">Add Admin</mat-checkbox>
|
||||
|
||||
@ -81,7 +81,7 @@ input[type=file]::file-selector-button {
|
||||
border: 7px solid #16c1a636;
|
||||
}
|
||||
.imgSizeValidation{
|
||||
color: red;
|
||||
color: blue;
|
||||
font-family: Didact Gothic, sans serif;
|
||||
}
|
||||
.mat-green:disabled {
|
||||
|
||||
@ -381,6 +381,7 @@ export class AddBusinessComponent implements OnInit {
|
||||
});
|
||||
this.selectedState = state;
|
||||
// this.selectedCity = null;
|
||||
this.form.controls['city'].setValue('')
|
||||
}
|
||||
|
||||
cityname(city){
|
||||
|
||||
@ -56,9 +56,10 @@
|
||||
<mat-error *ngIf="!form.get('email')?.errors?.required && (form.get('email')?.errors?.pattern)">
|
||||
Please enter a valid email address
|
||||
</mat-error>
|
||||
<mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
<mat-error *ngIf="myError('email', 'required')">Email is required</mat-error>
|
||||
<!-- <mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-error> -->
|
||||
<mat-error *ngIf="form.get('email').errors?.usernameTaken && form.get('email').dirty">
|
||||
Email already exists...
|
||||
</mat-error>
|
||||
@ -95,6 +96,10 @@
|
||||
<img *ngIf="imageViewStatus == true" class="image mb-2" [src]="url" height="150" width="150"><br/>
|
||||
<input type='file'accept="image/*" data-max-size="2048" style="width: 33%;" (change)="onSelectFile($event)" formControlName="logo"><br>
|
||||
<span *ngIf="imageViewStatus != true" class="imgSizeValidation">Upload Below 2MB <br> Supported File (jpg,jpeg and png)</span>
|
||||
<!-- Add mat-error for logo -->
|
||||
<mat-error *ngIf="form.get('logo').hasError('required')">Logo is required</mat-error>
|
||||
<mat-error *ngIf="form.get('logo').hasError('maxSizeExceeded')">File size exceeds 2MB</mat-error>
|
||||
<!-- Add more error conditions if needed -->
|
||||
<!-- <mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder="ConfirmPassword" matInput formControlName="confirmPassword">
|
||||
<mat-error *ngIf="myError('confirmPassword', 'required')">confirmPassword is required</mat-error>
|
||||
|
||||
@ -57,7 +57,7 @@ input[type=file]::file-selector-button {
|
||||
border: 7px solid #16c1a636;
|
||||
}
|
||||
.imgSizeValidation{
|
||||
color: red;
|
||||
color: blue;
|
||||
font-family: Didact Gothic, sans serif;
|
||||
}
|
||||
.user-mate{
|
||||
|
||||
@ -58,12 +58,13 @@ export class AddUserComponent implements OnInit {
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
let valData;
|
||||
if(this.action == 'Add'){
|
||||
valData= [this.validateUsernameAvailability.bind(this)]
|
||||
}else{
|
||||
valData = null
|
||||
}
|
||||
// let valData;
|
||||
// if(this.action == 'Add'){
|
||||
// valData= [this.validateUsernameAvailability.bind(this)]
|
||||
// }else{
|
||||
// valData = null
|
||||
// }
|
||||
let valData = [this.validateUsernameAvailability.bind(this)]
|
||||
this.hide = true;
|
||||
this.disableBus = localStorage.getItem('go_admin')
|
||||
this.userrole = localStorage.getItem('user_role')
|
||||
@ -81,7 +82,7 @@ export class AddUserComponent implements OnInit {
|
||||
password: new FormControl('', [Validators.required,Validators.pattern(
|
||||
'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*_=+-]).{8,16}$'
|
||||
)]),
|
||||
logo: new FormControl('', null),
|
||||
logo: new FormControl('', [Validators.required]),
|
||||
// confirmPassword: new FormControl('', [Validators.required, Validators.minLength(6)]),
|
||||
createdBy:new FormControl(this.userrole,null),
|
||||
});
|
||||
@ -123,7 +124,7 @@ export class AddUserComponent implements OnInit {
|
||||
// console.log(this.action,this.local_data)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
validateUsernameAvailability(control: FormControl) {
|
||||
let userRole = localStorage.getItem('user_role')
|
||||
@ -136,20 +137,31 @@ export class AddUserComponent implements OnInit {
|
||||
return this.http.post<any[]>(this.apiUrl + "getusers",param)
|
||||
.pipe(
|
||||
map((response:any) => {
|
||||
console.log(response)
|
||||
let apiList
|
||||
if(this.action == 'Add'){
|
||||
console.log('add')
|
||||
apiList = response.data
|
||||
}else{
|
||||
console.log('edit',this.local_data.id)
|
||||
let listData = response.data
|
||||
const newArray = listData.filter(item => item.id !== this.local_data.id);
|
||||
console.log(newArray)
|
||||
apiList = newArray
|
||||
}
|
||||
|
||||
console.log(response)
|
||||
let response1 = response.data
|
||||
let response1 = apiList
|
||||
let tmp=[];
|
||||
if(response1 instanceof Array){
|
||||
|
||||
response.data.forEach(element => {
|
||||
tmp.push(element.email)
|
||||
});
|
||||
console.log(tmp,`${control.value}`);
|
||||
return !tmp.includes(`${control.value}`) ? null : { usernameTaken: true };
|
||||
}else{
|
||||
return null
|
||||
}
|
||||
if(response1 instanceof Array){
|
||||
apiList.forEach(element => {
|
||||
tmp.push(element.email)
|
||||
});
|
||||
console.log(tmp,`${control.value}`);
|
||||
return !tmp.includes(`${control.value}`) ? null : { usernameTaken: true };
|
||||
}else{
|
||||
return null
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -219,6 +231,7 @@ export class AddUserComponent implements OnInit {
|
||||
this.form.controls['password'].updateValueAndValidity();
|
||||
}
|
||||
if (!this.form.valid) {
|
||||
this.notifierService.notify('warning', 'Please fill all the fields');
|
||||
return;
|
||||
}
|
||||
this.isSubmitting = true
|
||||
|
||||
@ -97,7 +97,7 @@ export class LoginComponent {
|
||||
this.router.navigate(['/services'])
|
||||
}
|
||||
} else{
|
||||
this.router.navigate(['/services'])
|
||||
this.router.navigate(['/services'])
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -122,6 +122,8 @@ export class LoginComponent {
|
||||
}
|
||||
this.router.navigate(['/home'])
|
||||
}
|
||||
}else{
|
||||
this.notifierService.notify('warning', res.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user