diff --git a/dashboard/src/scenes/stats/CustomFieldsStats.js b/dashboard/src/scenes/stats/CustomFieldsStats.js
index a93371bd6..a235fb98c 100644
--- a/dashboard/src/scenes/stats/CustomFieldsStats.js
+++ b/dashboard/src/scenes/stats/CustomFieldsStats.js
@@ -5,13 +5,6 @@ import { BlockDateWithTime, BlockTotal } from './Blocks';
import Card from '../../components/Card';
import { getMultichoiceBarData, getPieData } from './utils';
-function getColsSize(totalCols) {
- if (totalCols === 1) return 'full';
- if (totalCols === 2) return '1/2';
- if (totalCols % 4 === 0) return '1/3';
- return '1/4';
-}
-
const CustomFieldsStats = ({ customFields, data, additionalCols = [], dataTestId = '', help, onSliceClick, totalTitleForMultiChoice }) => {
const team = useRecoilValue(currentTeamState);
@@ -20,69 +13,63 @@ const CustomFieldsStats = ({ customFields, data, additionalCols = [], dataTestId
.filter((f) => f.enabled || f.enabledTeams?.includes(team._id))
.filter((f) => f.showInStats);
- const customFieldsNumber = customFieldsInStats.filter((field) => ['number'].includes(field.type));
- const customFieldsDate = customFieldsInStats.filter((field) => ['date', 'date-with-time'].includes(field.type));
- const customFieldsResponsivePie = customFieldsInStats.filter((field) => ['boolean', 'yes-no', 'enum'].includes(field.type));
- const customFieldsResponsiveBar = customFieldsInStats.filter((field) => ['multi-choice'].includes(field.type));
-
- const totalCols = customFieldsNumber.length + customFieldsDate.length + additionalCols.length;
-
- const colSize = getColsSize(totalCols);
-
return (
<>
- {totalCols > 0 && (
- <>
- {/* tailwind doesn't comile dynamic classes, so we need to declare them */}
-
-
- {additionalCols.map((col) => (
-
- {/* TODO: fix alignment. */}
-
} dataTestId={dataTestId} help={help?.(col.title.capitalize())} />
-
- ))}
- {customFieldsNumber.map((field) => (
-
+
+ {additionalCols.map((col) => (
+
+ {/* TODO: fix alignment. */}
+
} dataTestId={dataTestId} help={help?.(col.title.capitalize())} />
+
+ ))}
+ {customFieldsInStats.map((field) => {
+ if (['number'].includes(field.type)) {
+ return (
+
- ))}
- {customFieldsDate.map((field) => (
-
+ );
+ }
+ if (['date', 'date-with-time'].includes(field.type)) {
+ return (
+
- ))}
-
- >
- )}
- {customFieldsResponsivePie.map((field) => (
-
onSliceClick?.(newSlice, field.name) : undefined}
- key={field.name}
- data={getPieData(data, field.name, {
- options: field.options,
- isBoolean: field.type === 'boolean',
- })}
- />
- ))}
- {customFieldsResponsiveBar.map((field) => {
- return (
- onSliceClick?.(newSlice, field.name) : undefined}
- key={field.name}
- isMultiChoice
- axisTitleY="File active"
- axisTitleX={field.name}
- totalForMultiChoice={data.length}
- totalTitleForMultiChoice={totalTitleForMultiChoice}
- data={getMultichoiceBarData(data, field.name, { options: field.options })}
- />
- );
- })}
+ );
+ }
+ if (['boolean', 'yes-no', 'enum'].includes(field.type)) {
+ return (
+ onSliceClick?.(newSlice, field.name) : undefined}
+ key={field.name}
+ data={getPieData(data, field.name, {
+ options: field.options,
+ isBoolean: field.type === 'boolean',
+ })}
+ />
+ );
+ }
+ if (['multi-choice'].includes(field.type)) {
+ return (
+ onSliceClick?.(newSlice, field.name) : undefined}
+ key={field.name}
+ isMultiChoice
+ axisTitleY="File active"
+ axisTitleX={field.name}
+ totalForMultiChoice={data.length}
+ totalTitleForMultiChoice={totalTitleForMultiChoice}
+ data={getMultichoiceBarData(data, field.name, { options: field.options })}
+ />
+ );
+ }
+ return null;
+ })}
+
>
);
};
diff --git a/dashboard/src/scenes/stats/General.js b/dashboard/src/scenes/stats/General.js
index 39407955b..0b08f3971 100644
--- a/dashboard/src/scenes/stats/General.js
+++ b/dashboard/src/scenes/stats/General.js
@@ -19,7 +19,7 @@ const GeneralStats = ({
-
+
Statistiques des {title}
-