Skip to content

Commit

Permalink
feat: move messages to central contants.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlukasse committed Jan 25, 2023
1 parent f5f83f5 commit 51bc25e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]);
Expand Down
11 changes: 11 additions & 0 deletions src/Analysis/GWASV2/Utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};

0 comments on commit 51bc25e

Please sign in to comment.