Skip to content

Commit

Permalink
sign up page validations, stylings and feed component created
Browse files Browse the repository at this point in the history
  • Loading branch information
Gururajj77 committed Jan 10, 2024
1 parent 004541c commit 2c1c8c0
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Routes } from '@angular/router';
import { SignInComponent } from './sign-in/sign-in.component';
import { SignUpComponent } from './sign-up/sign-up.component';
import { FeedComponent } from './feed/feed.component';

export const routes: Routes = [
{ path: '', redirectTo: '/sign-in', pathMatch: 'full' },
{ path: 'sign-in', component: SignInComponent },
{ path: 'register-user', component: SignUpComponent },
{ path: 'feed', component: FeedComponent }
];
1 change: 1 addition & 0 deletions src/app/feed/feed.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>feed works!</p>
Empty file.
23 changes: 23 additions & 0 deletions src/app/feed/feed.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { FeedComponent } from './feed.component';

describe('FeedComponent', () => {
let component: FeedComponent;
let fixture: ComponentFixture<FeedComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FeedComponent]
})
.compileComponents();

fixture = TestBed.createComponent(FeedComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions src/app/feed/feed.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-feed',
standalone: true,
imports: [],
templateUrl: './feed.component.html',
styleUrl: './feed.component.scss'
})
export class FeedComponent {

}
4 changes: 4 additions & 0 deletions src/app/sign-in/sign-in.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class SignInComponent {
const email = this.loginForm.get('email')!.value;
const password = this.loginForm.get('password')!.value;
signInWithEmailAndPassword(this.auth, email, password)
.then((result) => {
this.router.navigateByUrl('/feed');
})
.catch((error) => {
this.ERROR_CODE = error.code
console.log(this.ERROR_CODE)
Expand All @@ -47,6 +50,7 @@ export class SignInComponent {
signInWithPopup(this.auth, provider)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
this.router.navigateByUrl('/feed')
}).catch((error) => {
const credential = GoogleAuthProvider.credentialFromError(error);
});
Expand Down
8 changes: 5 additions & 3 deletions src/app/sign-up/sign-up.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ <h2 class="heading">Create Account</h2>
<button [disabled]="!registerForm.valid" type="submit">Sign Up</button>
</div>
</form>
<a href="#" (click)="signInWithGoogle()" class="google-sign-in"
>Or log in with Google</a
>
<div class="help-text">
<button (click)="signInWithGoogle()" class="google-sign-in">
Or Login with Google
</button>
</div>
<div class="register-link">
<p>Already have an account? <a (click)="toLoginPage()">Log in</a></p>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/app/sign-up/sign-up.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ button:disabled {
}

.google-sign-in {
background: none;
border: none;
color: #757575;
cursor: pointer;
font-size: inherit;
font-family: inherit;
font-size: 14px;
margin-top: 16px;
margin-top: 10px;
text-decoration: none;
}

Expand Down
7 changes: 3 additions & 4 deletions src/app/sign-up/sign-up.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, inject } from '@angular/core';
import { Auth, GoogleAuthProvider, createUserWithEmailAndPassword, signInWithPopup, updateProfile } from '@angular/fire/auth';
import { Router } from '@angular/router';
import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';

@Component({
selector: 'app-sign-up',
Expand Down Expand Up @@ -37,7 +37,7 @@ export class SignUpComponent {
return updateProfile(userCredential.user, { displayName: name });
})
.then(() => {
// this.router.navigate(['/some-success-route']);
this.router.navigateByUrl('/feed');
})
.catch(error => {
console.error('Registration error:', error);
Expand All @@ -50,12 +50,11 @@ export class SignUpComponent {
signInWithPopup(this.auth, provider)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
this.router.navigateByUrl('/feed');
}).catch((error) => {
const errorCode = error.code;
const credential = GoogleAuthProvider.credentialFromError(error);
});
}

toLoginPage() {
this.router.navigateByUrl('sign-in')
}
Expand Down

0 comments on commit 2c1c8c0

Please sign in to comment.