Skip to content

Commit

Permalink
feat(fetch_employee_data): add specific "Not found" error message
Browse files Browse the repository at this point in the history
also make the generic error message clearer in Finnish

refs YJDH-689 (noticed the error message was generic)
  • Loading branch information
karisal-anders committed Jan 26, 2024
1 parent 22a581d commit 9d667f3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion frontend/kesaseteli/employer/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"remove_employment": "Delete the information",
"fetch_employment": "Load information",
"fetch_employment_error_title": "Error occured!",
"fetch_employment_error_message": "Could not fetch the info of the employee."
"fetch_employment_error_message": "Could not fetch the info of the employee.",
"fetch_employment_not_found_error_message": "Employee's information was not found."
},
"step3": {
"name": "Send",
Expand Down
3 changes: 2 additions & 1 deletion frontend/kesaseteli/employer/public/locales/fi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"remove_employment": "Poista tiedot",
"fetch_employment": "Hae tiedot",
"fetch_employment_error_title": "Sattui virhe!",
"fetch_employment_error_message": "Ei hakenut työntekijän tietoja."
"fetch_employment_error_message": "Ei pystytty hakemaan työntekijän tietoja.",
"fetch_employment_not_found_error_message": "Työntekijän tietoja ei löytynyt."
},
"step3": {
"name": "Lähetä",
Expand Down
3 changes: 2 additions & 1 deletion frontend/kesaseteli/employer/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"remove_employment": "Ta bort uppgifterna",
"fetch_employment": "Hämta uppgifter",
"fetch_employment_error_title": "Fel uppstod!",
"fetch_employment_error_message": "Kunde inte hämta arbetstagarens uppgifter."
"fetch_employment_error_message": "Kunde inte hämta arbetstagarens uppgifter.",
"fetch_employment_not_found_error_message": "Arbetstagarens information hittades inte."
},
"step3": {
"name": "Skicka",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,29 @@ const useApplicationApi = <T = Application>(
},
{
onSuccess: (data) => {
const { employer_summer_voucher_id, ...updatedData } = data;
const {employer_summer_voucher_id, ...updatedData} = data;
updateEmployment(
draftApplication,
employmentIndex,
updatedData,
onSuccess
);
},
onError: () =>
showErrorToast(
t('common:application.step2.fetch_employment_error_title'),
t('common:application.step2.fetch_employment_error_message')
),
onError: (error: unknown) => {
if (Axios.isAxiosError(error) && error.response.status === 404) {
// Not found error
showErrorToast(
t('common:application.step2.fetch_employment_error_title'),
t('common:application.step2.fetch_employment_not_found_error_message')
)
} else {
// General error
showErrorToast(
t('common:application.step2.fetch_employment_error_title'),
t('common:application.step2.fetch_employment_error_message')
)
}
}
}
);
};
Expand Down

0 comments on commit 9d667f3

Please sign in to comment.