fix: localize API error messages
Build and publish Docker images / Build and publish images (push) Successful in 2m35s
Build and publish Docker images / Build and publish images (push) Successful in 2m35s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
import { parseAPIErrorResponse } from 'dashboard/store/utils/api';
|
||||
import analyticsHelper from 'dashboard/helper/AnalyticsHelper/index';
|
||||
|
||||
/**
|
||||
@@ -20,5 +21,12 @@ export const useTrack = (...args) => {
|
||||
* @param {Object|null} action - Optional callback function or object to execute.
|
||||
*/
|
||||
export const useAlert = (message, action = null) => {
|
||||
emitter.emit('newToastMessage', { message, action });
|
||||
const normalizedMessage =
|
||||
message === null || message === undefined || message === ''
|
||||
? message
|
||||
: parseAPIErrorResponse(message);
|
||||
emitter.emit('newToastMessage', {
|
||||
message: normalizedMessage,
|
||||
action,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user