@@ -28,18 +28,17 @@ const ROLE_COLOR_MAP = {
2828import CustomTooltip from '../../CustomTooltip' ;
2929
3030const RoleDistributionPieChart = ( { roleDistributionStats = [ ] , isLoading, darkMode } ) => {
31-
3231 // Reusable function to sort data and assign colors.
33- const sortDataAndAssignColors = ( statsData ) => {
32+ const sortDataAndAssignColors = statsData => {
3433 statsData ?. sort ( ( a , b ) => b . count - a . count ) ;
3534 const mappedData = statsData ?. map ( ( item , index ) => ( {
36- name : item . _id ,
37- value : item . count ,
38- // Use a stable role mapping first, otherwise fallback by index.
39- color : ROLE_COLOR_MAP [ item . _id ] || COLORS [ index % COLORS . length ] ,
40- } ) ) ;
41- return mappedData ;
42- }
35+ name : item . _id ,
36+ value : item . count ,
37+ // Use a stable role mapping first, otherwise fallback by index.
38+ color : ROLE_COLOR_MAP [ item . _id ] || COLORS [ index % COLORS . length ] ,
39+ } ) ) ;
40+ return mappedData ;
41+ } ;
4342
4443 if ( isLoading ) {
4544 return (
@@ -51,13 +50,13 @@ const RoleDistributionPieChart = ({ roleDistributionStats = [], isLoading, darkM
5150 ) ;
5251 }
5352
54- let data = [ ] ;
53+ let data = [ ] ;
5554 // This is to handle the case when we are comparing the data with other time periods. In that case, the data structure is different and we need to access the comparison data.
56- if ( roleDistributionStats ?. comparison ) {
57- data = sortDataAndAssignColors ( roleDistributionStats ?. comparison ) ;
55+ if ( roleDistributionStats ?. comparison ) {
56+ data = sortDataAndAssignColors ( roleDistributionStats ?. comparison ) ;
5857 }
5958 // Fallback to the original data structure when we are not comparing the data with other time periods.
60- else {
59+ else {
6160 data = sortDataAndAssignColors ( roleDistributionStats ) ;
6261 }
6362
0 commit comments