Skip to content

Commit 5743d6a

Browse files
authored
Merge pull request #233 from CapstoneProjectCMC/feature/ulr-user-learning-resources
Feature/ulr user learning resources
2 parents c3a8b94 + e517608 commit 5743d6a

File tree

3 files changed

+48
-30
lines changed

3 files changed

+48
-30
lines changed

src/app/core/router-manager/vetical-menu-dynamic/statistics-vetical-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function sidebarStatisticsRouter(roles: string[]): SidebarItem[] {
3030
path: '/codecampus-statistics/user-payment-statistics',
3131
label: 'Thống kê nạp & mua',
3232
icon: 'fa-solid fa-credit-card',
33-
isVisible: !roles.includes(auth_lv2[0]),
33+
isVisible: roles.length > 0,
3434
},
3535
];
3636
}

src/app/features/statistics/pages/user-payment-statistic/user-payment-statistic.component.ts

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,7 @@ export class UserPaymentStatisticsComponent implements OnInit, OnDestroy {
2828
// dữ liệu thẻ
2929
purchaseAmount = 0;
3030
depositAmount = 0;
31-
// table
32-
tablePurchaseHeaders = [
33-
{ label: 'Ngày', value: 'day' },
34-
{ label: 'Số tiền nạp', value: 'depositAmount' },
35-
];
36-
tableDepositHeaders = [
37-
{ label: 'Ngày', value: 'day' },
38-
{ label: 'Số tiền mua', value: 'purchaseAmount' },
39-
];
31+
4032
fakeStats = [
4133
{
4234
day: '2025-09-11',
@@ -134,22 +126,7 @@ export class UserPaymentStatisticsComponent implements OnInit, OnDestroy {
134126
}
135127

136128
this.loadPayment();
137-
//chuẩn bị dữ liệu cho biểu đồ
138-
this.convertToChartData(this.paymentData);
139-
140-
this.calculateTotals(this.paymentData);
141-
// ✅ Gán dữ liệu BE vào chart
142-
const { categories, seriesData } = this.convertToChartData(
143-
this.paymentData
144-
);
145-
this.chartCategories = categories;
146-
this.chartSeries = seriesData;
147129

148-
// ✅ Tính tổng nạp + chi
149-
this.calculateTotals(this.paymentData);
150-
151-
// ✅ Chuẩn bị dữ liệu 2 bảng
152-
this.splitDataForTables(this.paymentData);
153130
// this.convertToChartData(this.fakeStats);
154131
// // ✅ Gán fake data vào chart
155132
// const { categories, seriesData } = this.convertToChartData(this.fakeStats);
@@ -175,6 +152,9 @@ export class UserPaymentStatisticsComponent implements OnInit, OnDestroy {
175152

176153
// ✅ Chuẩn bị dữ liệu 2 bảng
177154
this.splitDataForTables(this.paymentData);
155+
console.log('Filtered Data:', this.paymentData);
156+
console.log(this.chartCategories);
157+
console.log(this.chartSeries);
178158
}
179159

180160
loadPayment(): void {
@@ -188,6 +168,23 @@ export class UserPaymentStatisticsComponent implements OnInit, OnDestroy {
188168
next: (response) => {
189169
if (response && response.result) {
190170
this.paymentData = response.result;
171+
console.log('Fetched Data:', this.paymentData);
172+
//chuẩn bị dữ liệu cho biểu đồ
173+
this.convertToChartData(this.paymentData);
174+
175+
this.calculateTotals(this.paymentData);
176+
// ✅ Gán dữ liệu BE vào chart
177+
const { categories, seriesData } = this.convertToChartData(
178+
this.paymentData
179+
);
180+
this.chartCategories = categories;
181+
this.chartSeries = seriesData;
182+
183+
// ✅ Tính tổng nạp + chi
184+
this.calculateTotals(this.paymentData);
185+
186+
// ✅ Chuẩn bị dữ liệu 2 bảng
187+
this.splitDataForTables(this.paymentData);
191188
} else {
192189
this.error = 'Dữ liệu trả về không hợp lệ.';
193190
}
@@ -210,7 +207,11 @@ export class UserPaymentStatisticsComponent implements OnInit, OnDestroy {
210207
}
211208

212209
convertToChartData(data: any[]) {
213-
const categories = data.map((item) => item.day);
210+
const categories = data.map((item) => {
211+
item.day;
212+
console.log('Item day:', item.day);
213+
return item.day;
214+
});
214215

215216
const seriesData = [
216217
{
@@ -227,19 +228,36 @@ export class UserPaymentStatisticsComponent implements OnInit, OnDestroy {
227228
},
228229
];
229230

231+
console.log('categories:', categories);
232+
console.log('seriesData:', seriesData);
230233
return { categories, seriesData };
231234
}
235+
// table
236+
tableDepositHeaders = [
237+
{ label: 'Ngày', value: 'day' },
238+
{ label: 'Số tiền nạp', value: 'depositAmount' },
239+
];
240+
tablePurchaseHeaders = [
241+
{ label: 'Ngày', value: 'day' },
242+
{ label: 'Số tiền mua', value: 'purchaseAmount' },
243+
];
232244
splitDataForTables(data: any[]) {
245+
// formatter chung cho VNĐ
246+
const formatter = new Intl.NumberFormat('vi-VN', {
247+
style: 'currency',
248+
currency: 'VND',
249+
});
250+
233251
// Bảng nạp tiền
234252
this.tableDepositData = data.map((item) => ({
235253
day: item.day,
236-
depositAmount: item.depositAmount,
254+
depositAmount: formatter.format(item.depositAmount), // format tại đây
237255
}));
238256

239257
// Bảng mua hàng
240258
this.tablePurchaseData = data.map((item) => ({
241259
day: item.day,
242-
purchaseAmount: item.purchaseAmount,
260+
purchaseAmount: formatter.format(item.purchaseAmount), // format tại đây
243261
}));
244262
}
245263

src/app/shared/components/my-shared/multi-line-chart/multi-line-chart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ export class MultiLineChartComponent implements OnChanges {
6565
},
6666
yaxis: {
6767
title: {
68-
text: 'Amount ($)',
68+
text: 'Amount (VND)',
6969
},
7070
},
7171
tooltip: {
7272
y: {
7373
formatter: function (val: number) {
74-
return val + ' $';
74+
return val + ' VND';
7575
},
7676
},
7777
},

0 commit comments

Comments
 (0)