diff --git a/client/src/components/gauge/index.jsx b/client/src/components/gauge/index.jsx index ba8a374a..673393db 100644 --- a/client/src/components/gauge/index.jsx +++ b/client/src/components/gauge/index.jsx @@ -1,31 +1,31 @@ /* eslint-disable no-mixed-operators */ import PropTypes from 'prop-types'; +import React from 'react'; import { Tooltip } from 'react-tooltip'; import './gauge.scss'; export default function Gauge({ data }) { - const gaugeValuesInPercent = data.map((item) => ( - { ...item, valuePercentage: (item.value / data.reduce((acc, curr) => acc + curr.value, 0) * 100).toFixed(0) } + const dataWithPercent = data.map((item) => ( + { ...item, percentage: (item.value / data.reduce((acc, curr) => acc + curr.value, 0) * 100).toFixed(0) } )); return (
- {gaugeValuesInPercent.filter((item) => item.value > 0).map((item) => ( - <> + {dataWithPercent.filter((item) => item.value > 0).map((item) => ( +
- {`${item.label} (${item.value} ie. ${item.valuePercentage} %)`} + {`${item.label} (${item.value} ie. ${item.percentage} %)`}
- {`${item.label} (${item.value} ie. ${item.valuePercentage} %)`} + {`${item.label} (${item.value} ie. ${item.percentage} %)`} - +
))}
); diff --git a/client/src/pages/home/index.jsx b/client/src/pages/home/index.jsx index 2504ba26..72426af1 100644 --- a/client/src/pages/home/index.jsx +++ b/client/src/pages/home/index.jsx @@ -340,9 +340,7 @@ export default function Home() { ({ - className: st.id, - id: st.id, - label: st.label, + ...st, value: allAffiliations.filter((affiliation) => affiliation.status === st.id).length, }))} /> @@ -373,11 +371,9 @@ export default function Home() { ({ - className: status[st].id, - id: status[st].id, - label: status[st].label, - value: allPublications.filter((publication) => publication.status === status[st].id).length, + data={Object.values(status).map((st) => ({ + ...st, + value: allPublications.filter((publication) => publication.status === st.id).length, }))} /> @@ -460,16 +456,14 @@ export default function Home() { - + {renderButtons(selectedDatasets, tagWorks)} ({ - className: status[st].id, - id: status[st].id, - label: status[st].label, - value: allDatasets.filter((dataset) => dataset.status === status[st].id).length, + data={Object.values(status).map((st) => ({ + ...st, + value: allDatasets.filter((dataset) => dataset.status === st.id).length, }))} />