Skip to content

Commit

Permalink
feat(attritionTableHistogramModal): Ran linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisraymond-uchicago committed Sep 24, 2024
1 parent 7d6661e commit 2532457
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import './AttritionTable.css';

const { Panel } = Collapse;

const AttritionTable = ({ selectedCohort, outcome, covariates, tableType }) => {
const AttritionTable = ({
selectedCohort, outcome, covariates, tableType,
}) => {
const [modalInfo, setModalInfo] = useState({
title: '',
isModalOpen: false,
Expand All @@ -21,9 +23,9 @@ const AttritionTable = ({ selectedCohort, outcome, covariates, tableType }) => {
useEffect(() => {
setModalInfo({
...modalInfo,
selectedCohort: selectedCohort,
covariates: covariates,
outcome: outcome,
selectedCohort,
covariates,
outcome,
});
}, [selectedCohort, covariates, outcome]);

Expand Down Expand Up @@ -137,29 +139,29 @@ const AttritionTable = ({ selectedCohort, outcome, covariates, tableType }) => {
/>
</React.Fragment>
)}
{selectedCohort?.cohort_definition_id &&
outcome &&
covariatesProcessed.length > 0
{selectedCohort?.cohort_definition_id
&& outcome
&& covariatesProcessed.length > 0
? covariatesProcessed.map((item) => (
<React.Fragment key={item}>
{/* This is for all the covariate rows in the table */}
<AttritionTableRow
key={item}
outcome={outcome}
// use the last item
rowObject={item[item.length - 1]}
selectedCohort={selectedCohort}
rowType='Covariate'
covariates={covariates}
currentCovariateAndCovariatesFromPrecedingRows={[
...item,
applyAutoGenFilters(),
]}
modalInfo={modalInfo}
setModalInfo={setModalInfo}
/>
</React.Fragment>
))
<React.Fragment key={item}>
{/* This is for all the covariate rows in the table */}
<AttritionTableRow
key={item}
outcome={outcome}
// use the last item
rowObject={item[item.length - 1]}
selectedCohort={selectedCohort}
rowType='Covariate'
covariates={covariates}
currentCovariateAndCovariatesFromPrecedingRows={[
...item,
applyAutoGenFilters(),
]}
modalInfo={modalInfo}
setModalInfo={setModalInfo}
/>
</React.Fragment>
))
: null}
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ const AttritionTableRow = ({
],
// if there are not two cohorts selected, then quantitative
// Otherwise if there are two cohorts selected, case control
() =>
fetchConceptStatsByHareSubset(
cohortDefinitionId,
currentCovariateAndCovariatesFromPrecedingRows,
outcome,
sourceId
),
queryConfig
() => fetchConceptStatsByHareSubset(
cohortDefinitionId,
currentCovariateAndCovariatesFromPrecedingRows,
outcome,
sourceId,
),
queryConfig,
);

const breakdown = data?.concept_breakdown;
Expand All @@ -51,13 +50,13 @@ const AttritionTableRow = ({
if (breakdown?.length) {
const filteredBreakdown = breakdown.filter(
// eslint-disable-next-line camelcase
({ concept_value }) => concept_value !== 'OTH'
({ concept_value }) => concept_value !== 'OTH',
);
setBreakdownSize(
filteredBreakdown.reduce(
(acc, curr) => acc + curr.persons_in_cohort_with_value,
0
)
0,
),
);
setBreakdownColumns(filteredBreakdown);
} else {
Expand All @@ -75,7 +74,7 @@ const AttritionTableRow = ({
const getSizeByColumn = (hare) => {
const hareIndex = breakdownColumns.findIndex(
// eslint-disable-next-line camelcase
({ concept_value }) => concept_value === hare
({ concept_value }) => concept_value === hare,
);
return hareIndex > -1
? breakdownColumns[hareIndex].persons_in_cohort_with_value
Expand All @@ -97,8 +96,8 @@ const AttritionTableRow = ({
}
throw new Error(
`Invalid Row Type: ${rowType} and rowObject.variable_type ${JSON.stringify(
rowObject
)} combination`
rowObject,
)} combination`,
);
}
return null;
Expand All @@ -119,7 +118,7 @@ const AttritionTableRow = ({
return selectedCohort.cohort_name;
}
throw new Error(
`Invalid Row Type: ${rowType}. Expected one of ['Outcome', 'Covariate', 'Cohort']`
`Invalid Row Type: ${rowType}. Expected one of ['Outcome', 'Covariate', 'Cohort']`,
);
};

Expand Down Expand Up @@ -147,7 +146,7 @@ const AttritionTableRow = ({
...modalInfo,
title: determineModalTitle(),
isModalOpen: true,
rowObject: rowObject,
rowObject,
});
};

Expand Down

0 comments on commit 2532457

Please sign in to comment.