diff --git a/source/components/publicodesUtils.tsx b/source/components/publicodesUtils.tsx index 3ac14c590..490144310 100644 --- a/source/components/publicodesUtils.tsx +++ b/source/components/publicodesUtils.tsx @@ -303,7 +303,7 @@ const categoryColorOverride = { } export function extractCategories( - rules: any, + rules: NGCRules, engine: Engine, valuesFromURL?: any, parentRule = MODEL_ROOT_RULE_NAME, diff --git a/source/pages/groupe-dashboard/components/VotreEmpreinte.tsx b/source/pages/groupe-dashboard/components/VotreEmpreinte.tsx index d65c91329..fe85eaec9 100644 --- a/source/pages/groupe-dashboard/components/VotreEmpreinte.tsx +++ b/source/pages/groupe-dashboard/components/VotreEmpreinte.tsx @@ -1,3 +1,4 @@ +import { Category } from '@/components/publicodesUtils' import { formatValue } from 'publicodes' import { Trans } from 'react-i18next' import { ValueObject } from '../hooks/useGetGroupStats' @@ -5,11 +6,15 @@ import PercentageDiff from './PercentageDiff' export default function VotreEmpreinte({ categoriesFootprints, + categories, membersLength, }: { - categoriesFootprints?: Record | undefined + categoriesFootprints: Record | undefined + categories: Category[] membersLength: number }) { + console.log('categories', categories) + console.log('categoriesFootprints', categoriesFootprints) return ( <>

@@ -23,39 +28,43 @@ export default function VotreEmpreinte({
    {Object.entries(categoriesFootprints ?? {}).reduce( - (acc, [key, { icon, title, variation, value }]) => { - if (!icon || !title) return acc - return [ - ...acc, -
  • -
    -
    - {icon} -
    -
    -
    - {title} + (acc, [key, { icon, title, variation, value, isCategory }]) => { + return title !== undefined && icon !== undefined && isCategory + ? // categories.find( + // ({ dottedName }) => dottedName === title.toLowerCase() + // ) + [ + ...acc, +
  • +
    +
    + {icon} +
    +
    +
    + {title} +
    +
    + {membersLength > 1 && ( + + )}
    - - {membersLength > 1 && ( - - )} - -
    -
    - - {formatValue(value / 1000, { - precision: 1, - })} - {' '} - t -
    -
    -
  • , - ] +
    +
    + + {formatValue(value / 1000, { + precision: 1, + })} + {' '} + t +
    +
    + , + ] + : acc }, [] as JSX.Element[] )} diff --git a/source/pages/groupe-dashboard/index.tsx b/source/pages/groupe-dashboard/index.tsx index 25751e299..781fd8780 100644 --- a/source/pages/groupe-dashboard/index.tsx +++ b/source/pages/groupe-dashboard/index.tsx @@ -26,6 +26,7 @@ import { matomoEventUpdateGroupName } from '@/analytics/matomo-events' import Button from '@/components/groupe/Button' import InlineTextInput from '@/components/groupe/InlineTextInput' import Separator from '@/components/groupe/Separator' +import { extractCategories } from '@/components/publicodesUtils' import AutoCanonicalTag from '@/components/utils/AutoCanonicalTag' import { useGetCurrentSimulation } from '@/hooks/useGetCurrentSimulation' @@ -54,6 +55,8 @@ export default function GroupeDashboard() { }) const engine = useEngine() + const rules = useSelector((state: AppState) => state.rules) + const categories = extractCategories(rules, engine) const currentSimulation = useGetCurrentSimulation() @@ -224,6 +227,7 @@ export default function GroupeDashboard() {