- Timestamp:
- 12/19/21 19:39:00 (3 years ago)
- Branches:
- master
- Children:
- bdd6491
- Parents:
- 1ad8e64
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/homepage/homepage.component.ts
r1ad8e64 r84d0fbb 1 1 import { Component, OnInit } from '@angular/core'; 2 import { Router } from '@angular/router'; 2 3 import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'; 4 import { LoginRequest } from '../_models/dto/loginRequest'; 5 import { UserDto } from '../_models/dto/userDto'; 3 6 import { Location } from '../_models/location'; 4 7 import { LocationService } from '../_services/location.service'; 8 import { UserService } from '../_services/user.service'; 9 import { LoginComponent } from './login/login.component'; 5 10 import { RegisterComponent } from './register/register.component'; 6 11 … … 20 25 ref: DynamicDialogRef; 21 26 22 constructor(private locationService: LocationService, private dialogService: DialogService) { 27 constructor(private locationService: LocationService, private dialogService: DialogService, private userService: UserService, 28 private router: Router) { 23 29 this.responsiveOptions = [ 24 30 { … … 44 50 45 51 ngOnInit(): void { 46 52 /* 47 53 this.locationService.getWeekendGetaways().subscribe( 48 54 data => { … … 55 61 } 56 62 ); 63 */ 57 64 } 58 65 59 onClickSignUp(){ 60 console.log("VLEGOV"); 66 onClickSignUp() { 61 67 this.ref = this.dialogService.open(RegisterComponent, { 62 68 header: 'Register form', … … 64 70 contentStyle: { "max-height": "500px", "overflow": "auto" }, 65 71 baseZIndex: 10000 66 }); 72 }); 73 74 this.ref.onClose.subscribe((user: UserDto) => { 75 this.userService.registerUser(user).subscribe( 76 data => { 77 console.log(data); 78 79 } 80 ); 81 }); 82 } 83 84 85 onClickLogIn() { 86 this.ref = this.dialogService.open(LoginComponent, { 87 header: 'Log in if you already have an account', 88 width: '70%', 89 contentStyle: { "max-height": "500px", "overflow": "auto" }, 90 baseZIndex: 10000 91 }); 92 this.ref.onClose.subscribe((loginRequest : LoginRequest) => { 93 this.userService.authenticateUser(loginRequest).subscribe( 94 (data : any) => { 95 console.log(data); 96 if(this.userService.isUserLoggedIn()){ 97 this.router.navigate(['planners']); 98 } 99 } 100 ); 101 }); 67 102 } 68 103 }
Note:
See TracChangeset
for help on using the changeset viewer.