-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdash-content.component.ts
More file actions
69 lines (60 loc) · 1.79 KB
/
Copy pathdash-content.component.ts
File metadata and controls
69 lines (60 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { Component, OnInit } from '@angular/core';
import { ProductsService } from '../../../services/products/products.service';
import { CardModule } from 'primeng/card';
import { ButtonModule } from 'primeng/button';
import { DividerModule } from 'primeng/divider';
import { CurrencyPipe, NgClass, NgStyle } from '@angular/common';
import { DataViewModule } from 'primeng/dataview';
import { TagModule } from 'primeng/tag';
import { TableModule } from 'primeng/table';
import { Product } from '../../../models/Products.model';
import { AvatarModule } from 'primeng/avatar';
import { AvatarGroupModule } from 'primeng/avatargroup';
import { DashOrdersComponent } from '../dash-orders/dash-orders.component';
@Component({
selector: 'app-dash-content',
standalone: true,
imports: [
CardModule,
ButtonModule,
DividerModule,
NgStyle,
NgClass,
DataViewModule,
TagModule,
TableModule,
CurrencyPipe,
AvatarModule,
AvatarGroupModule,
DashOrdersComponent
],
templateUrl: './dash-content.component.html',
styleUrl: './dash-content.component.scss'
})
export class DashContentComponent implements OnInit {
products: Product[] = [];
constructor(
private prodService: ProductsService
) { }
ngOnInit(): void {
this.listBestSelling();
}
listBestSelling() {
this.prodService.getAllProducts(1, 30).subscribe({
next: (data) => {
let filterProds = data.slice(0, 5);
filterProds.forEach((item: Product) => {
item['amount'] = item.stock * item.price;
})
this.products = filterProds;
console.log(this.products)
},
error: (err) => {
console.log(err);
}
});
}
gerarNumeroAleatorio(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}