From 51bc25e075a5c6f5ef5d6617c8811bce02d63f26 Mon Sep 17 00:00:00 2001 From: pieterlukasse Date: Wed, 25 Jan 2023 19:49:04 +0100 Subject: [PATCH] feat: move messages to central `contants.js` --- .../CohortsOverlapDiagram/CohortsOverlapDiagram.jsx | 9 +++------ .../PhenotypeHistogram/PhenotypeHistogram.jsx | 10 +++------- src/Analysis/GWASV2/Utils/constants.js | 11 +++++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Analysis/GWASV2/Components/Diagrams/CohortsOverlapDiagram/CohortsOverlapDiagram.jsx b/src/Analysis/GWASV2/Components/Diagrams/CohortsOverlapDiagram/CohortsOverlapDiagram.jsx index 3d92a7c2ce..1349d8f6eb 100644 --- a/src/Analysis/GWASV2/Components/Diagrams/CohortsOverlapDiagram/CohortsOverlapDiagram.jsx +++ b/src/Analysis/GWASV2/Components/Diagrams/CohortsOverlapDiagram/CohortsOverlapDiagram.jsx @@ -10,11 +10,8 @@ import { import Simple3SetsEulerDiagram from './Simple3SetsEulerDiagram'; import { useSourceContext } from '../../../Utils/Source'; import ACTIONS from '../../../Utils/StateManagement/Actions'; +import MESSAGES from '../../../Utils/constants'; -const OVERLAP_ERROR = { - title: 'Your selected cohorts should have some overlap with the study population', - messageType: 'warning', -}; const CohortsOverlapDiagram = ({ dispatch, selectedStudyPopulationCohort, @@ -134,12 +131,12 @@ const CohortsOverlapDiagram = ({ || dataStudyPopulationAndControl.cohort_overlap.case_control_overlap === 0) { dispatch({ type: ACTIONS.ADD_MESSAGE, - payload: OVERLAP_ERROR, + payload: MESSAGES.OVERLAP_ERROR, }); } else { dispatch({ type: ACTIONS.DELETE_MESSAGE, - payload: OVERLAP_ERROR, + payload: MESSAGES.OVERLAP_ERROR, }); } } diff --git a/src/Analysis/GWASV2/Components/Diagrams/PhenotypeHistogram/PhenotypeHistogram.jsx b/src/Analysis/GWASV2/Components/Diagrams/PhenotypeHistogram/PhenotypeHistogram.jsx index b571b9704b..24c6a7abad 100644 --- a/src/Analysis/GWASV2/Components/Diagrams/PhenotypeHistogram/PhenotypeHistogram.jsx +++ b/src/Analysis/GWASV2/Components/Diagrams/PhenotypeHistogram/PhenotypeHistogram.jsx @@ -9,11 +9,7 @@ import { import Histogram from './Histogram'; import { useSourceContext } from '../../../Utils/Source'; import ACTIONS from '../../../Utils/StateManagement/Actions'; - -const NO_BINS_ERROR = { - title: 'None of the persons in the (remaining) population have a value for the selected concept', - messageType: 'warning', -}; +import MESSAGES from '../../../Utils/constants'; const PhenotypeHistogram = ({ dispatch, @@ -48,12 +44,12 @@ const PhenotypeHistogram = ({ if (data?.bins === null) { dispatch({ type: ACTIONS.ADD_MESSAGE, - payload: NO_BINS_ERROR, + payload: MESSAGES.NO_BINS_ERROR, }); } else { dispatch({ type: ACTIONS.DELETE_MESSAGE, - payload: NO_BINS_ERROR, + payload: MESSAGES.NO_BINS_ERROR, }); } }, [data]); diff --git a/src/Analysis/GWASV2/Utils/constants.js b/src/Analysis/GWASV2/Utils/constants.js index da869b3afe..387a7c186d 100644 --- a/src/Analysis/GWASV2/Utils/constants.js +++ b/src/Analysis/GWASV2/Utils/constants.js @@ -22,3 +22,14 @@ export const isEnterOrSpace = (event) => event.key === 'Enter' // TODO - move this and function above to a .js file with a clearer name? export const formatNumber = (number) => (Math.round(number * 10) / 10).toLocaleString(); + +export const MESSAGES = { + OVERLAP_ERROR: { + title: 'Your selected cohorts should have some overlap with the study population', + messageType: 'warning', + }, + NO_BINS_ERROR: { + title: 'None of the persons in the (remaining) population have a value for the selected concept', + messageType: 'warning', + }, +};