diff --git a/core/src/actions/auth.ts b/core/src/actions/auth.ts index 49fab04c..f05e0d69 100644 --- a/core/src/actions/auth.ts +++ b/core/src/actions/auth.ts @@ -86,18 +86,22 @@ export function loginUser(credentials: Credentials) { .then(user => { dispatch(authenticate(user)); }) - .catch((error: Error) => { + .catch((error: unknown) => { console.error(error); - dispatch( - addSnackbar({ - type: 'warning', - message: { - key: 'ui.toast.onFailToAuth', - message: error.message, - }, - }), - ); - dispatch(authError(error)); + if (error instanceof Error) { + dispatch( + addSnackbar({ + type: 'warning', + message: { + key: 'ui.toast.onFailToAuth', + options: { + details: error.message, + }, + }, + }), + ); + dispatch(authError(error)); + } }); }; } diff --git a/core/src/actions/entries.ts b/core/src/actions/entries.ts index f391b469..0fe996d6 100644 --- a/core/src/actions/entries.ts +++ b/core/src/actions/entries.ts @@ -624,7 +624,9 @@ export function loadEntry(collection: Collection, slug: string, silent = false) type: 'error', message: { key: 'ui.toast.onFailToLoadEntries', - details: error.message, + options: { + details: error.message, + }, }, }), ); @@ -744,7 +746,9 @@ export function loadEntries(collection: Collection, page = 0) { type: 'error', message: { key: 'ui.toast.onFailToLoadEntries', - details: error.message, + options: { + details: error.message, + }, }, }), ); @@ -803,7 +807,9 @@ export function traverseCollectionCursor(collection: Collection, action: string) type: 'error', message: { key: 'ui.toast.onFailToLoadEntries', - details: error.message, + options: { + details: error.message, + }, }, }), ); @@ -1071,7 +1077,9 @@ export function persistEntry(collection: Collection) { type: 'error', message: { key: 'ui.toast.onFailToPersist', - details: error, + options: { + details: error, + }, }, }), ); @@ -1102,7 +1110,9 @@ export function deleteEntry(collection: Collection, slug: string) { type: 'error', message: { key: 'ui.toast.onFailToDelete', - details: error, + options: { + details: error, + }, }, }), ); diff --git a/core/src/actions/mediaLibrary.ts b/core/src/actions/mediaLibrary.ts index 866c5791..e9fe4a93 100644 --- a/core/src/actions/mediaLibrary.ts +++ b/core/src/actions/mediaLibrary.ts @@ -337,7 +337,9 @@ export function persistMedia(file: File, opts: MediaOptions = {}) { type: 'error', message: { key: 'ui.toast.onFailToPersistMedia', - details: error, + options: { + details: error, + }, }, }), ); @@ -381,7 +383,9 @@ export function deleteMedia(file: MediaFile, opts: MediaOptions = {}) { type: 'error', message: { key: 'ui.toast.onFailToDeleteMedia', - details: error.message, + options: { + details: error.message, + }, }, }), ); @@ -417,7 +421,9 @@ export function deleteMedia(file: MediaFile, opts: MediaOptions = {}) { type: 'error', message: { key: 'ui.toast.onFailToDeleteMedia', - details: error.message, + options: { + details: error.message, + }, }, }), ); diff --git a/core/src/actions/status.ts b/core/src/actions/status.ts index 9a3768f4..e27191e7 100644 --- a/core/src/actions/status.ts +++ b/core/src/actions/status.ts @@ -55,7 +55,10 @@ export function checkBackendStatus() { dispatch( addSnackbar({ type: 'error', - message: { key: 'ui.toast.onBackendDown', details: status.api.statusPage }, + message: { + key: 'ui.toast.onBackendDown', + options: { details: status.api.statusPage }, + }, }), ); } diff --git a/core/src/backends/azure/AuthenticationPage.tsx b/core/src/backends/azure/AuthenticationPage.tsx index 924ccfe5..bc7c9b3e 100644 --- a/core/src/backends/azure/AuthenticationPage.tsx +++ b/core/src/backends/azure/AuthenticationPage.tsx @@ -34,7 +34,7 @@ const AzureAuthenticationPage = ({ if (err) { alert({ title: 'auth.errors.authTitle', - body: { key: 'auth.errors.authBody', options: { details: err } }, + body: { key: 'auth.errors.authBody', options: { details: err.toString() } }, }); return; } else if (data) { diff --git a/core/src/store/slices/snackbars.ts b/core/src/store/slices/snackbars.ts index d806f4b2..d840101e 100644 --- a/core/src/store/slices/snackbars.ts +++ b/core/src/store/slices/snackbars.ts @@ -11,9 +11,10 @@ export interface SnackbarMessage { type: MessageType; message: | string - | ({ + | { key: string; - } & Record); + options?: Record; + }; } // Define a type for the slice state