File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,19 @@ export default async function Page(props: {
6161 return total + categoryTotal ;
6262 } , 0 ) ;
6363
64+ // sort the categories by their sub-total
65+ const sortedCategories = usagePreview . data . result . sort ( ( a , b ) => {
66+ const aTotal = a . lineItems . reduce (
67+ ( sum , item ) => sum + item . amountUsdCents ,
68+ 0 ,
69+ ) ;
70+ const bTotal = b . lineItems . reduce (
71+ ( sum , item ) => sum + item . amountUsdCents ,
72+ 0 ,
73+ ) ;
74+ return bTotal - aTotal ;
75+ } ) ;
76+
6477 return (
6578 < div className = "flex flex-col gap-8" >
6679 { usagePreview . data . planVersion < 5 && (
@@ -112,7 +125,7 @@ export default async function Page(props: {
112125 </ Card >
113126
114127 < div className = "space-y-6" >
115- { usagePreview . data . result . map ( ( category , index ) => (
128+ { sortedCategories . map ( ( category , index ) => (
116129 < UsageCategoryDetails
117130 key = { `${ category . category } _${ index } ` }
118131 category = { category }
You can’t perform that action at this time.
0 commit comments