Skip to content

Commit

Permalink
[React] fix spelling of Toast
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekmore committed Dec 17, 2024
1 parent 7d8d583 commit d16c52e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ import { isAxiosError } from 'axios';
import { FieldErrorVM, isProblemWithMessage } from 'app/shared/jhipster/problem-details';
import { getMessageFromHeaders } from 'app/shared/jhipster/headers';

type TostMessage = {
type ToastMessage = {
message?: string;
<%_ if (enableTranslation) { _%>
key?: string;
data?: any;
<%_ } _%>
};

const addErrorAlert = (message: TostMessage) => {
const addErrorAlert = (message: ToastMessage) => {
<%_ if (enableTranslation) { _%>
toast.error(message.key ? translate(message.key, message.data) ?? message.message : message.message);
<%_ } else { _%>
toast.error(message.message);
<%_ } _%>
};

const getFieldErrorsTosts = (fieldErrors: FieldErrorVM[]): TostMessage[] =>
const getFieldErrorsToasts = (fieldErrors: FieldErrorVM[]): ToastMessage[] =>
fieldErrors.map(fieldError => {
if (['Min', 'Max', 'DecimalMin', 'DecimalMax'].includes(fieldError.message)) {
fieldError.message = 'Size';
Expand Down Expand Up @@ -102,7 +102,7 @@ export default () => next => action => {
const { data } = response;
const problem = isProblemWithMessage(data) ? data : null;
if (problem?.fieldErrors) {
getFieldErrorsTosts(problem.fieldErrors).forEach(message => addErrorAlert(message));
getFieldErrorsToasts(problem.fieldErrors).forEach(message => addErrorAlert(message));
} else {
const { error: toastError<% if (enableTranslation) { %>, param<% } %> } = getMessageFromHeaders((response.headers as any) ?? {});
if (toastError) {
Expand Down

0 comments on commit d16c52e

Please sign in to comment.