diff --git a/src-ts/lib/functions/error-functions/error.functions.tsx b/src-ts/lib/functions/error-functions/error.functions.tsx new file mode 100644 index 000000000..a4b017c15 --- /dev/null +++ b/src-ts/lib/functions/error-functions/error.functions.tsx @@ -0,0 +1,29 @@ +import { Link } from 'react-router-dom' +import { toast, ToastContent } from 'react-toastify' + +import { contactSupportPath } from '../../contact-support-form' +import { logError } from '../logging-functions' + +export function handle(error: any, errString?: string): void { + + logError(error) + + const errorContent: ToastContent = ( + <> +
+ {errString ?? error.response?.data?.result?.content ?? error.message ?? error} + {' '} + Please try again later or + {' '} + + Contact Support + . +
+ > + ) + + toast.error(errorContent) +} diff --git a/src-ts/lib/functions/error-functions/index.ts b/src-ts/lib/functions/error-functions/index.ts new file mode 100644 index 000000000..80f039765 --- /dev/null +++ b/src-ts/lib/functions/error-functions/index.ts @@ -0,0 +1 @@ +export { handle as errorHandle } from './error.functions' diff --git a/src-ts/lib/functions/index.ts b/src-ts/lib/functions/index.ts index 59ebaa379..3bf2087c5 100644 --- a/src-ts/lib/functions/index.ts +++ b/src-ts/lib/functions/index.ts @@ -6,6 +6,7 @@ export { authUrlLogout, authUrlSignup, } from './authentication-functions' +export * from './error-functions' export * from './file-functions' export * from './logging-functions' export * from './text-format-functions' diff --git a/src-ts/lib/index.ts b/src-ts/lib/index.ts index 89bd96720..c5ef84cd7 100644 --- a/src-ts/lib/index.ts +++ b/src-ts/lib/index.ts @@ -10,9 +10,12 @@ export { authUrl, authUrlLogin, authUrlLogout, + authUrlSignup, + errorHandle, fileCreateFromCanvas, fileDownloadBlob, fileDownloadCanvasAsImage, + logError, logInfo, logInitialize, textFormatDateLocaleShortString, diff --git a/src-ts/lib/loading-spinner/LoadingSpinner.tsx b/src-ts/lib/loading-spinner/LoadingSpinner.tsx index 7a6b81617..9f735cd77 100644 --- a/src-ts/lib/loading-spinner/LoadingSpinner.tsx +++ b/src-ts/lib/loading-spinner/LoadingSpinner.tsx @@ -11,12 +11,17 @@ import styles from './LoadingSpinner.module.scss' export interface LoadingSpinnerProps { className?: string - show?: boolean + hide?: boolean } -const LoadingSpinner: FC