wip: profile component

This commit is contained in:
Jegor 2021-06-17 10:30:40 +02:00
parent b748b9492a
commit 9821c004ec
5 changed files with 25 additions and 19 deletions

View File

@ -36,8 +36,8 @@ export class RegistrationComponent implements OnInit {
onSubmit() { onSubmit() {
this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe( this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe(
res=> { res=> {
this.router.navigate(['']);
this.api.saveSessionInfoToLocalStorage(res); this.api.saveSessionInfoToLocalStorage(res);
this.router.navigate(['/']);
} }
); );
} }

View File

@ -11,7 +11,7 @@ export class ProfileComponent implements OnInit {
currentUser: any; currentUser: any;
obj:any; obj:any;
alarms: any []; alarms: any [];
productsMap: any; productsMap: any = {};
constructor(private api: ApiService ) { } constructor(private api: ApiService ) { }
@ -37,7 +37,7 @@ export class ProfileComponent implements OnInit {
} }
getProductsByIds(): void { getProductsByIds(): void {
let productIds: number []; let productIds: number [] = [];
this.alarms.forEach( this.alarms.forEach(
alarm => {productIds.push(alarm.product_id)} alarm => {productIds.push(alarm.product_id)}
); );

View File

@ -2,7 +2,7 @@
<div class="container"> <div class="container">
<a class="navbar-brand" routerLink=""> Betterzon</a> <a class="navbar-brand" routerLink=""> Betterzon</a>
<form class="form-inline my-2 my-lg-0"> <form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" (keyup.enter)="getSearchedProducts()"> <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" (keyup.enter)="getSearchedProducts()" [(ngModel)]="searchQuery">
</form> </form>
<button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu Menu

View File

@ -10,20 +10,23 @@ import {Router} from "@angular/router";
}) })
export class TopBarComponent implements OnInit { export class TopBarComponent implements OnInit {
sidenav: any; sidenav: any;
isLoggedIn: boolean; isLoggedIn: boolean;
@Input() searchQuery: string; searchQuery: string;
constructor( constructor(
private api: ApiService, private api: ApiService,
private router: Router private router: Router
) { } ) {
}
ngOnInit() { ngOnInit() {
this.api.getUserInfo().subscribe(data=>{console.log(data)}); this.api.getUserInfo().subscribe(data => {
console.log(data)
});
if ( this.api.getSessionInfoFromLocalStorage().session_id != "") { if (this.api.getSessionInfoFromLocalStorage().session_id != "") {
this.isLoggedIn = true; this.isLoggedIn = true;
} }
} }
@ -35,10 +38,12 @@ export class TopBarComponent implements OnInit {
} }
getSearchedProducts(): void { getSearchedProducts(): void {
this.api.getProductsByQuery(this.searchQuery).subscribe( console.log(this.searchQuery);
data => { this.redirectTo('/search', {queryParams: {q: this.searchQuery}});
this.router.navigate([('/registration')]); }
}
); redirectTo(uri: string, queryParams: object): void {
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() =>
this.router.navigate([uri], queryParams));
} }
} }

View File

@ -1,6 +1,7 @@
<div id="mainComponents"> <div id="mainComponents">
<app-product-list numberOfProducts="20" [showProductPicture]="true" searchQuery="{{searchTerm}}" <app-product-list numberOfProducts="20" [showProductPicture]="true" searchQuery="{{searchTerm}}"
type="search"></app-product-list> type="search"></app-product-list>
</div> </div>
<app-footer></app-footer> <app-bottom-bar></app-bottom-bar>