Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

credentials data trimmed #103

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 42 additions & 28 deletions src/app/component/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { AppState } from 'src/app/app-store/app.state';
import { setLoadingSpinner } from 'src/app/component/shared/state/Shared/shared.actions';
import { getLoading, getLogoLoading } from 'src/app/component/shared/state/Shared/shared.selector';
import {
getLoading,
getLogoLoading,
} from 'src/app/component/shared/state/Shared/shared.selector';
import { loginStart } from '../state/auth.actions';

@Component({
Expand All @@ -15,44 +18,55 @@ import { loginStart } from '../state/auth.actions';
})
export class LoginComponent implements OnInit {
password!: string;
constructor(private router: Router,private store:Store<AppState>, private titleService: Title) {}
loginForm!:FormGroup
constructor(
private router: Router,
private store: Store<AppState>,
private titleService: Title
) {}
loginForm!: FormGroup;
ngOnInit(): void {
this.titleService.setTitle("Login - TaskEasy.in");
this.titleService.setTitle('Login - TaskEasy.in');
this.loginForm = new FormGroup({
email: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('',[ Validators.required, Validators.minLength(8)]),
});
this.store.select(getLoading).pipe().forEach((value)=>{
if(value==true){
this.titleService.setTitle("Checking your credentials...");
}
else{
this.titleService.setTitle("Login - TaskEasy.in");
}
password: new FormControl('', [
Validators.required,
Validators.minLength(8),
]),
});
this.store
.select(getLoading)
.pipe()
.forEach((value) => {
if (value == true) {
this.titleService.setTitle('Checking your credentials...');
} else {
this.titleService.setTitle('Login - TaskEasy.in');
}
});

this.store.select(getLogoLoading).pipe().forEach((value)=>{
if(value==true){
this.titleService.setTitle("Checking your credentials...");
}
else{
this.titleService.setTitle("Login - TaskEasy.in");
}
});
this.store
.select(getLogoLoading)
.pipe()
.forEach((value) => {
if (value == true) {
this.titleService.setTitle('Checking your credentials...');
} else {
this.titleService.setTitle('Login - TaskEasy.in');
}
});
}

onSignUpClick (this:any) {
onSignUpClick(this: any) {
this.router.navigateByUrl('/signup');
};
}

onSignInSubmit(){
if(this.loginForm.invalid){
return
onSignInSubmit() {
if (this.loginForm.invalid) {
return;
}

const email = this.loginForm.value.email;
const password = this.loginForm.value.password;
const email = this.loginForm.value.email.trim();
const password = this.loginForm.value.password.trim();
this.store.dispatch(setLoadingSpinner({ status: true }));
this.store.dispatch(loginStart({ email, password }));
}
Expand Down
67 changes: 40 additions & 27 deletions src/app/component/auth/signup/signup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,75 @@ import { Store } from '@ngrx/store';
import { MessageService } from 'primeng/api';
import { Observable } from 'rxjs';
import { AppState } from 'src/app/app-store/app.state';
import { setLoadingSpinner, setLogoLoading } from 'src/app/component/shared/state/Shared/shared.actions';
import { getErrorMessage, getLoading, getLogoLoading } from 'src/app/component/shared/state/Shared/shared.selector';
import {
setLoadingSpinner,
setLogoLoading,
} from 'src/app/component/shared/state/Shared/shared.actions';
import {
getErrorMessage,
getLoading,
getLogoLoading,
} from 'src/app/component/shared/state/Shared/shared.selector';
import { signupStart } from '../state/auth.actions';

@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css'],

})
export class SignupComponent implements OnInit {
signUpForm!: FormGroup;
errorMessage!:Observable<string>;
constructor(private router: Router,private store :Store<AppState>, private titleService: Title) {}

errorMessage!: Observable<string>;
constructor(
private router: Router,
private store: Store<AppState>,
private titleService: Title
) {}

confirmPassword(signUpForm: FormGroup) {
return signUpForm.controls['newPassword'].value === signUpForm.controls['repeatNewPassword'].value ? null : {'mismatch': true};
return signUpForm.controls['newPassword'].value ===
signUpForm.controls['repeatNewPassword'].value
? null
: { mismatch: true };
}
ngOnInit(): void {
this.titleService.setTitle("Signup - TaskEasy.in");
this.titleService.setTitle('Signup - TaskEasy.in');
this.signUpForm = new FormGroup({
firstname: new FormControl('', Validators.required),
lastname: new FormControl('', Validators.required),
email: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('', [ Validators.required, Validators.minLength(8)]),

password: new FormControl('', [
Validators.required,
Validators.minLength(8),
]),
});

this.store.select(getLogoLoading).pipe().forEach((value)=>{
if(value==true){
this.titleService.setTitle("checking......");
}
else{
this.titleService.setTitle("Signup - TaskEasy.in");
}
});

this.store
.select(getLogoLoading)
.pipe()
.forEach((value) => {
if (value == true) {
this.titleService.setTitle('checking......');
} else {
this.titleService.setTitle('Signup - TaskEasy.in');
}
});
}

onSignUpSubmit() {
console.log('SignUp');
const firstname = this.signUpForm.value.firstname
const lastname = this.signUpForm.value.lastname
const email = this.signUpForm.value.email
const password = this.signUpForm.value.password
const firstname = this.signUpForm.value.firstname.trim();
const lastname = this.signUpForm.value.lastname.trim();
const email = this.signUpForm.value.email.trim();
const password = this.signUpForm.value.password.trim();
if (this.signUpForm.invalid) {
return;
}
this.store.dispatch(setLogoLoading({ status: true }));
this.store.dispatch(signupStart({firstname,lastname,email,password}))
this.store.dispatch(signupStart({ firstname, lastname, email, password }));
console.log('SignUp');
}
onSignInClick(this: any) {
this.router.navigateByUrl('/login');
}


}