@@ -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
0 commit comments