Skip to content

Commit

Permalink
commit final
Browse files Browse the repository at this point in the history
  • Loading branch information
jccastiblancor committed Dec 12, 2019
1 parent 804d435 commit a33495c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 54 deletions.
5 changes: 5 additions & 0 deletions src/app/app-routing/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ import { ClienteDetailComponent } from '../cliente/cliente-detail/cliente-detail
import { ClienteCreateComponent } from '../cliente/cliente-create/cliente-create.component';
import { PaginaDashboardComponent } from '../pagina-dashboard/pagina-dashboard.component';
import { ClienteCarritoComponent } from '../cliente/cliente-carrito/cliente-carrito.component';
import { MapaComponent } from '../mapa/mapa.component';

const routes: Routes = [

{
path: 'carrito',
component: ClienteCarritoComponent
},
{
path: 'mapa',
component: MapaComponent
},
{
path: 'authors',
children: [
Expand Down
6 changes: 6 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
</li>
</div>

<div *ngIf="isCliente()">
<li class="nav-item">
<a class="nav-link texto-blanco" routerLink="/mapa" routerLinkActive="active">Tracking pedido</a>
</li>
</div>

<div *ngIf="isAdmin()">
<li class="nav-item">
<a class="nav-link texto-blanco" (click)='getId()' routerLink="/books/list"
Expand Down
4 changes: 4 additions & 0 deletions src/app/pagina-dashboard/pagina-dashboard.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}

.color-cafe{
color: #8c6a58;
}
33 changes: 23 additions & 10 deletions src/app/pagina-dashboard/pagina-dashboard.component.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<div class="scrolling-wrapper">
<h1 class='color-cafe'>
mis libros
</h1>

<div class="card mr-5" style="width: 10rem;" *ngFor="let e of bestsellers">
<img class="card-img-top" src={{e.image}} alt="Card image cap">
<div class="card-body">
<h5 class="card-title">{{e.name}}</h5>
<p class="card-text">{{e.description}}</p>
<a href="#" class="btn btn-primary mr-5">Ver Mas</a>
<a href="#" class="btn btn-primary">Agregar al Carrito</a>

<div *ngIf="esVacia()">
<div class="card" style="width: 18rem;">
<img src="https://cdn4.iconfinder.com/data/icons/basic-ui-colour/512/ui-39-512.png" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">No has comprado libros</h5>
<p class="card-text">Selecciona un libro para ver detalles y agregarlo a tu carrito.</p>
</div>
</div>
</div>
<div *ngIf="!esVacia()">
<div class="scrolling-wrapper">


</div>
<div class="card mr-5" style="width: 10rem;" *ngFor="let e of books">
<img class="card-img-top" src={{e.image}} alt="Card image cap">
<div class="card-body">
<h5 class="card-title">{{e.name}}</h5>
<p class="card-text">{{e.description}}</p>
<a href="#" class="btn btn-primary mr-5">Ver Mas</a>
</div>
</div>


</div>
</div>
62 changes: 18 additions & 44 deletions src/app/pagina-dashboard/pagina-dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { BookService } from '../book/book.service';
import { Book } from '../book/book';
import { ClienteService } from '../cliente/cliente.service';
import { ClienteDetail } from '../cliente/cliente-detail';

@Component({
selector: 'app-pagina-dashboard',
Expand All @@ -9,63 +11,35 @@ import { Book } from '../book/book';
})
export class PaginaDashboardComponent implements OnInit {

constructor(private bs: BookService) { }
constructor(private cs: ClienteService) { }

books: Book[];
booksSorteable: Book[];
bestsellers: Book[];
novedades: Book[];
descuentos: Book[];
cliente: ClienteDetail;


ngOnInit() {
this.getCliente();
this.getBooks();
this.booksSorteable = this.books;
this.getBestsellers();
this.getNovedades();
this.getDescuentos();
}

getBooks(): void {
this.bs.getBooks()
.subscribe(books => {
this.books = books;
});
this.books = this.cliente.libros_comprados;
}

getBestsellers(): void {
console.log("booksSorteable");
console.log(this.books);
console.log(this.booksSorteable);
this.booksSorteable.sort((b1, b2) => b1.vendidos - b2.vendidos);


for (let e of this.booksSorteable) {

if (this.bestsellers.length < 5) {
this.bestsellers.push(e);
}
}
getCliente(): void {
this.cs.getClienteDetail(+localStorage.getItem('id'))
.subscribe(c => {
this.cliente = c;
});
}

getNovedades(): void {
this.booksSorteable.sort((b1, b2) => b1.publishingdate - b2.publishingdate);

for (let e of this.booksSorteable) {
if (this.novedades.length < 5) {
this.novedades.push(e);
}
esVacia():boolean {
if(this.books.length==0){
return true;
}
}

getDescuentos(): void {


for (let e of this.booksSorteable) {
if (e.descuento>0){
this.descuentos.push(e);
}
}
else {
return false;
}

}

}

0 comments on commit a33495c

Please sign in to comment.