fleet/frontend/pages/AccountPage/helpers.ts
jacobshandling 78f520b467
Have the UI inform the user why they could not update their password (#23398)
## #23341 

<img width="1305" alt="Screenshot 2024-10-30 at 10 13 27 AM"
src="https://github.com/user-attachments/assets/c085f77c-4620-4f62-9f2c-0fe7fd9dec8b">

- [x] Changes file added for user-visible changes in `changes/`
- [x] Manual QA for all new/changed functionality
- [ ] Cherry-pick and PR into RC

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-10-30 11:14:50 -07:00

16 lines
422 B
TypeScript

import { getErrorReason } from "interfaces/errors";
const DEFAULT_ERROR_MESSAGE = "Could not update. Please try again.";
// eslint-disable-next-line import/prefer-default-export
export const getErrorMessage = (e: unknown) => {
let errorMessage = getErrorReason(e, {
reasonIncludes: "Cannot reuse old password",
});
if (!errorMessage) {
errorMessage = DEFAULT_ERROR_MESSAGE;
}
return errorMessage;
};