1
1
import { calculateTotalCost , getMonthlyCostData } from '@/constants' ;
2
2
import { QuarterlyCost } from '@/types/private-cloud' ;
3
- import { formatDate } from '@/utils/js/date' ;
3
+ import { formatDate , getMonthNameFromNumber } from '@/utils/js/date' ;
4
4
import { formatCurrency } from '@/utils/js/number' ;
5
5
6
6
export default function QuarterlyCostTable ( { data } : { data : QuarterlyCost } ) {
@@ -10,18 +10,18 @@ export default function QuarterlyCostTable({ data }: { data: QuarterlyCost }) {
10
10
< thead >
11
11
< tr className = "bg-gray-100 dark:bg-gray-800" >
12
12
< th className = "text-left p-2 border-b" > Date Range</ th >
13
- < th className = "text-right p-2 border-b" > CPU (cores)</ th >
14
- < th className = "text-right p-2 border-b" > Storage (GiB)</ th >
15
- < th className = "text-right p-2 border-b" > CPU Cost</ th >
16
- < th className = "text-right p-2 border-b" > Storage Cost</ th >
17
- < th className = "text-right p-2 border-b" > Total Cost</ th >
13
+ < th className = "text-center p-2 border-b" > CPU (cores)</ th >
14
+ < th className = "text-center p-2 border-b" > Storage (GiB)</ th >
15
+ < th className = "text-center p-2 border-b" > CPU Cost</ th >
16
+ < th className = "text-center p-2 border-b" > Storage Cost</ th >
17
+ < th className = "text-center p-2 border-b" > Total Cost</ th >
18
18
</ tr >
19
19
</ thead >
20
20
< tbody >
21
21
{ data . items . length > 0 ? (
22
22
data . items . map ( ( item , idx : number ) => (
23
23
< tr key = { idx } className = { idx % 2 === 0 ? 'bg-white dark:bg-gray-900' : 'bg-gray-50 dark:bg-gray-800' } >
24
- < td className = "p-2 border-b align-top " >
24
+ < td className = "p-2 border-b text-left " >
25
25
{ formatDate ( item . startDate , 'yyyy-MM-dd HH:mm' ) } –{ ' ' }
26
26
{ formatDate ( item . endDate , 'yyyy-MM-dd HH:mm' ) } { ' ' }
27
27
{ item . isArchived && (
@@ -35,11 +35,11 @@ export default function QuarterlyCostTable({ data }: { data: QuarterlyCost }) {
35
35
</ span >
36
36
) }
37
37
</ td >
38
- < td className = "p-2 border-b text-right align-top " > { item . total . cpu . value } </ td >
39
- < td className = "p-2 border-b text-right align-top " > { item . total . storage . value } </ td >
40
- < td className = "p-2 border-b text-right align-top " > { formatCurrency ( item . total . cpu . cost ) } </ td >
41
- < td className = "p-2 border-b text-right align-top " > { formatCurrency ( item . total . storage . cost ) } </ td >
42
- < td className = "p-2 border-b text-right align-top " > { formatCurrency ( item . total . subtotal . cost ) } </ td >
38
+ < td className = "p-2 border-b text-left " > { item . total . cpu . value } </ td >
39
+ < td className = "p-2 border-b text-center " > { item . total . storage . value } </ td >
40
+ < td className = "p-2 border-b text-center " > { formatCurrency ( item . total . cpu . cost ) } </ td >
41
+ < td className = "p-2 border-b text-center " > { formatCurrency ( item . total . storage . cost ) } </ td >
42
+ < td className = "p-2 border-b text-center " > { formatCurrency ( item . total . subtotal . cost ) } </ td >
43
43
</ tr >
44
44
) )
45
45
) : (
@@ -54,46 +54,44 @@ export default function QuarterlyCostTable({ data }: { data: QuarterlyCost }) {
54
54
< table className = "w-full text-sm border-collapse mt-6" >
55
55
< thead >
56
56
< tr className = "bg-gray-100 dark:bg-gray-800" >
57
- < th className = "text-left p-2 border-b" > Day </ th >
58
- < th className = "text-right p-2 border-b" > CPU (Cores)</ th >
59
- < th className = "text-right p-2 border-b" > CPU Cost</ th >
60
- < th className = "text-right p-2 border-b" > Storage (GiB)</ th >
61
- < th className = "text-right p-2 border-b" > Storage Cost</ th >
62
- < th className = "text-right p-2 border-b" > Total Cost</ th >
57
+ < th className = "text-center p-2 border-b" > Month </ th >
58
+ < th className = "text-center p-2 border-b" > CPU (Cores)</ th >
59
+ < th className = "text-center p-2 border-b" > CPU Cost</ th >
60
+ < th className = "text-center p-2 border-b" > Storage (GiB)</ th >
61
+ < th className = "text-center p-2 border-b" > Storage Cost</ th >
62
+ < th className = "text-center p-2 border-b" > Total Cost</ th >
63
63
</ tr >
64
64
</ thead >
65
65
< tbody >
66
66
{ data . months . map ( ( month , idx : number ) => {
67
67
const totalCost = data . monthDetails . cpuToDate [ idx ] + data . monthDetails . storageToDate [ idx ] ;
68
68
return (
69
69
< tr key = { idx } className = { idx % 2 === 0 ? 'bg-white dark:bg-gray-900' : 'bg-gray-50 dark:bg-gray-800' } >
70
- < td className = "p-2 border-b text-right align-top " > { month } </ td >
71
- < td className = "p-2 border-b text-right align-top " >
70
+ < td className = "p-2 border-b text-center " > { getMonthNameFromNumber ( month ) } </ td >
71
+ < td className = "p-2 border-b text-center " >
72
72
{ totalCost === 0 ? 'N/A' : data . discreteResourceValues [ month ] . cpu }
73
73
</ td >
74
- < td className = "p-2 border-b text-right align-top " >
74
+ < td className = "p-2 border-b text-center " >
75
75
{ totalCost === 0 ? 'N/A' : formatCurrency ( data . monthDetails . cpuToDate [ idx ] ) }
76
76
</ td >
77
- < td className = "p-2 border-b text-right align-top " >
77
+ < td className = "p-2 border-b text-center " >
78
78
{ totalCost === 0 ? 'N/A' : data . discreteResourceValues [ month ] . storage }
79
79
</ td >
80
- < td className = "p-2 border-b text-right align-top " >
80
+ < td className = "p-2 border-b text-center " >
81
81
{ totalCost === 0 ? 'N/A' : formatCurrency ( data . monthDetails . storageToDate [ idx ] ) }
82
82
</ td >
83
- < td className = "p-2 border-b text-right align-top" >
84
- { totalCost === 0 ? 'N/A' : formatCurrency ( totalCost ) }
85
- </ td >
83
+ < td className = "p-2 border-b text-center" > { totalCost === 0 ? 'N/A' : formatCurrency ( totalCost ) } </ td >
86
84
</ tr >
87
85
) ;
88
86
} ) }
89
87
</ tbody >
90
88
< tfoot >
91
89
< tr >
92
90
< td colSpan = { 4 } />
93
- < td colSpan = { 1 } className = "p-2 text-left " >
91
+ < td colSpan = { 1 } className = "p-2 border-b text-center " >
94
92
< strong > Current total cost for { data . billingPeriod } </ strong >
95
93
</ td >
96
- < td colSpan = { 1 } className = "p-2 text-left " >
94
+ < td colSpan = { 1 } className = "p-2 border-b text-center " >
97
95
< strong > { formatCurrency ( calculateTotalCost ( getMonthlyCostData ( data ) ) ) } </ strong >
98
96
</ td >
99
97
</ tr >
0 commit comments