Skip to content

Commit

Permalink
Merge pull request #31 from JMTheo/ajuste-operacao-home
Browse files Browse the repository at this point in the history
Adequando a home com o novo card de classificacao e ajuste na data
  • Loading branch information
JMTheo authored Jun 6, 2021
2 parents 2fe293d + 929e54e commit 57f17f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ export class LancamentosModalComponent implements OnInit {
}

ngOnInit() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<ion-col [ngStyle]="corTexto()"> {{ valor }} </ion-col>
</ion-row>
</ion-grid>
</ion-card>
</ion-card>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export class UltimosLancamentosComponent implements OnInit {
@Input() tipoOperacao: string;



ngOnInit() {
this.diaCompra = new Date(this.diaCompra).toLocaleDateString();
}

corTexto() {
Expand Down Expand Up @@ -47,8 +48,8 @@ export class UltimosLancamentosComponent implements OnInit {
break;
}

case 'investimentos': {
this.srcImg = "https://static.vecteezy.com/ti/vetor-gratis/p1/2519573-investimento-grafico-icone-design-ilustracao-vetor.jpg"
case 'investimentos': {
this.srcImg = "https://static.vecteezy.com/ti/vetor-gratis/p1/2519573-investimento-grafico-icone-design-ilustracao-vetor.jpg"
break;
}
case 'alimentacao': {
Expand All @@ -63,4 +64,4 @@ export class UltimosLancamentosComponent implements OnInit {
}
return this.srcImg;
}
}
}
6 changes: 3 additions & 3 deletions src/app/pages/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ <h1 class="vlr-home">R$ {{ valorDinamico }}</h1>
<ion-col>
<ion-title>Últimas transações</ion-title>
<div *ngFor="let i of listaLancamentosCard">
<app-ultimos-lancamentos *ngIf="i.tipoTransacao == estadoCategoria"
srcImg="https://i.pinimg.com/originals/83/04/31/830431f04b70f189d95cd42e4bf1d502.jpg"
<app-ultimos-lancamentos *ngIf="i.tipoOperacao == estadoCategoria"
diaCompra = {{i.diaCompra}}
titulo= {{i.titulo}}
valor= {{i.valor}}
tipoTransacao={{i.tipoTransacao}}
tipoOperacao={{i.tipoOperacao}}
></app-ultimos-lancamentos>
</div>

</ion-col>
</ion-grid>
</div>
</ion-content>
</ion-content>
17 changes: 10 additions & 7 deletions src/app/pages/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export class HomePage implements OnInit {
};
if (this.listaLancamentos) {
this.listaLancamentos.forEach((el) => {
if (el.tipoTransacao == 'entrada') {
if (el.tipoOperacao == 'entrada') {
entradas.valores.push(el.valor);
entradas.data.push(el.diaCompra);
entradas.data.push(new Date(el.diaCompra).toLocaleDateString());
entradas.total += el.valor;
} else {
saidas.data.push(el.diaCompra);
saidas.data.push(new Date(el.diaCompra).toLocaleDateString());
saidas.valores.push(el.valor);
saidas.total += el.valor;
}
Expand Down Expand Up @@ -120,9 +120,12 @@ export class HomePage implements OnInit {
}
async retornaTodosLancamentos() {
let arr = await this.storage.retornaTodosLancamentos();
console.log(arr)
this.listaLancamentos = arr;
this.listaLancamentosCard = arr.slice().sort((a: Lancamento, b: Lancamento) =>
new Date(b.diaCompra).getTime() - new Date(a.diaCompra).getTime())
if(arr) {
console.log(arr)
this.listaLancamentos = arr;
this.listaLancamentosCard = arr.slice().sort((a: Lancamento, b: Lancamento) =>
new Date(b.diaCompra).getTime() - new Date(a.diaCompra).getTime())
}

}
}

0 comments on commit 57f17f2

Please sign in to comment.