Skip to content

Commit

Permalink
fix: format and style error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Dec 9, 2024
1 parent ae28856 commit 8ea2a39
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
10 changes: 8 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-29T14:57:51.495Z\n"
"PO-Revision-Date: 2024-11-29T14:57:51.496Z\n"
"POT-Creation-Date: 2024-12-09T10:23:24.850Z\n"
"PO-Revision-Date: 2024-12-09T10:23:24.851Z\n"

msgid "view only"
msgstr "view only"
Expand Down Expand Up @@ -171,6 +171,9 @@ msgstr "No data"
msgid "Expression description"
msgstr "Expression description"

msgid "Error loading value"
msgstr "Error loading value"

msgid "None"
msgstr "None"

Expand Down Expand Up @@ -258,6 +261,9 @@ msgstr "Indicator type"
msgid "Decimals in output"
msgstr "Decimals in output"

msgid "There was a problem loading information for this data item."
msgstr "There was a problem loading information for this data item."

msgid "Name"
msgstr "Name"

Expand Down
9 changes: 7 additions & 2 deletions src/components/DataDimension/Info/CalculationInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const calculationQuery = {
export const CalculationInfo = ({ id, displayNameProp }) => {
const [data, setData] = useState()
const [error, setError] = useState()
const [expressionError, setExpressionError] = useState()
const [loading, setLoading] = useState(true)

const { baseUrl, apiVersion } = useConfig()

const engine = useDataEngine()
const [getHumanReadableExpression] = useDataMutation(
validateIndicatorExpressionMutation,
{ onError: setError }
{ onError: setExpressionError }
)

const fetchData = useCallback(async () => {
Expand Down Expand Up @@ -74,7 +75,11 @@ export const CalculationInfo = ({ id, displayNameProp }) => {
data.calculation.humanReadableExpression
)
) : (
<span className="none">{i18n.t('None')}</span>
<span className="none">
{expressionError
? i18n.t('Error loading value')
: i18n.t('None')}
</span>
)}
</td>
</tr>
Expand Down
10 changes: 9 additions & 1 deletion src/components/DataDimension/Info/InfoTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@ export const InfoTable = ({ data, error, loading, children }) => {
</Center>
</div>
)}
{error && 'some error occured'}
{error && (
<div className="error">
<span>
{i18n.t(
'There was a problem loading information for this data item.'
)}
</span>
</div>
)}
{data && (
<>
<table className="data-table">
Expand Down
8 changes: 8 additions & 0 deletions src/components/DataDimension/Info/styles/InfoPopover.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export default css`
height: 100%;
width: 100%;
}
.error {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
color: ${colors.grey700};
}
.data-table {
display: table;
width: 100%;
Expand Down

0 comments on commit 8ea2a39

Please sign in to comment.