Skip to content

Commit

Permalink
refactor: pass data item type to InfoTable
Browse files Browse the repository at this point in the history
Needed for computing the url to Maintenance app.
  • Loading branch information
edoardo committed Dec 18, 2024
1 parent 3dd2a6b commit 7286c2a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/components/DataDimension/Info/CalculationInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const calculationQuery = {
},
}

export const CalculationInfo = ({ id, displayNameProp }) => {
export const CalculationInfo = ({ id, displayNameProp, type }) => {
const [data, setData] = useState()
const [error, setError] = useState()
const [expressionError, setExpressionError] = useState()
Expand Down Expand Up @@ -71,7 +71,12 @@ export const CalculationInfo = ({ id, displayNameProp }) => {

return (
<>
<InfoTable data={data?.calculation} loading={loading} error={error}>
<InfoTable
type={type}
data={data?.calculation}
loading={loading}
error={error}
>
<tr>
<th>{i18n.t('Expression description')}</th>
<td>
Expand All @@ -97,4 +102,5 @@ export const CalculationInfo = ({ id, displayNameProp }) => {
CalculationInfo.propTypes = {
displayNameProp: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
}
10 changes: 8 additions & 2 deletions src/components/DataDimension/Info/DataElementInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ const dataElementQuery = {
},
}

export const DataElementInfo = ({ id, displayNameProp }) => {
export const DataElementInfo = ({ id, displayNameProp, type }) => {
const { loading, error, data } = useDataQuery(dataElementQuery, {
variables: { id, displayNameProp },
})

return (
<>
<InfoTable data={data?.dataElement} loading={loading} error={error}>
<InfoTable
type={type}
data={data?.dataElement}
loading={loading}
error={error}
>
<tr>
<th>{i18n.t('Data set(s)')}</th>
<td>
Expand Down Expand Up @@ -116,4 +121,5 @@ export const DataElementInfo = ({ id, displayNameProp }) => {
DataElementInfo.propTypes = {
displayNameProp: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
}
4 changes: 3 additions & 1 deletion src/components/DataDimension/Info/DataElementOperandInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const dataElementOperandsQuery = {
},
}

export const DataElementOperandInfo = ({ id, displayNameProp }) => {
export const DataElementOperandInfo = ({ id, displayNameProp, type }) => {
const [data, setData] = useState()
const [error, setError] = useState()
const [loading, setLoading] = useState(true)
Expand Down Expand Up @@ -85,6 +85,7 @@ export const DataElementOperandInfo = ({ id, displayNameProp }) => {
return (
<>
<InfoTable
type={type}
data={data?.dataElementOperand}
loading={loading}
error={error}
Expand Down Expand Up @@ -222,4 +223,5 @@ export const DataElementOperandInfo = ({ id, displayNameProp }) => {
DataElementOperandInfo.propTypes = {
displayNameProp: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
}
10 changes: 8 additions & 2 deletions src/components/DataDimension/Info/DataSetInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ const dataSetQuery = {
},
}

export const DataSetInfo = ({ id, displayNameProp }) => {
export const DataSetInfo = ({ id, displayNameProp, type }) => {
const { loading, error, data } = useDataQuery(dataSetQuery, {
variables: { id, displayNameProp },
})

return (
<>
<InfoTable data={data?.dataSet} loading={loading} error={error}>
<InfoTable
type={type}
data={data?.dataSet}
loading={loading}
error={error}
>
<tr>
<th>{i18n.t('Period type')}</th>
<td>{data?.dataSet.periodType}</td>
Expand Down Expand Up @@ -83,4 +88,5 @@ export const DataSetInfo = ({ id, displayNameProp }) => {
DataSetInfo.propTypes = {
displayNameProp: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
}
2 changes: 1 addition & 1 deletion src/components/DataDimension/Info/EventDataItemInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const EventDataItemInfo = ({ type, id, displayNameProp }) => {

const renderInfoTable = (data) => (
<>
<InfoTable data={data} loading={loading} error={error}>
<InfoTable type={type} data={data} loading={loading} error={error}>
<tr>
<th>{i18n.t('Type')}</th>
<td>
Expand Down
10 changes: 8 additions & 2 deletions src/components/DataDimension/Info/IndicatorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const indicatorQuery = {
},
}

export const IndicatorInfo = ({ id, displayNameProp }) => {
export const IndicatorInfo = ({ id, displayNameProp, type }) => {
const [data, setData] = useState()
const [error, setError] = useState()
const [loading, setLoading] = useState(true)
Expand Down Expand Up @@ -71,7 +71,12 @@ export const IndicatorInfo = ({ id, displayNameProp }) => {

return (
<>
<InfoTable data={data?.indicator} loading={loading} error={error}>
<InfoTable
type={type}
data={data?.indicator}
loading={loading}
error={error}
>
<tr>
<th>{i18n.t('Numerator description')}</th>
<td>
Expand Down Expand Up @@ -179,4 +184,5 @@ export const IndicatorInfo = ({ id, displayNameProp }) => {
IndicatorInfo.propTypes = {
displayNameProp: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
}
4 changes: 3 additions & 1 deletion src/components/DataDimension/Info/ProgramIndicatorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const programIndicatorQuery = {
},
}

export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
export const ProgramIndicatorInfo = ({ id, displayNameProp, type }) => {
const [data, setData] = useState()
const [error, setError] = useState()
const [loading, setLoading] = useState(true)
Expand Down Expand Up @@ -88,6 +88,7 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
return (
<>
<InfoTable
type={type}
data={data?.programIndicator}
loading={loading}
error={error}
Expand Down Expand Up @@ -212,4 +213,5 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
ProgramIndicatorInfo.propTypes = {
displayNameProp: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
}

0 comments on commit 7286c2a

Please sign in to comment.