|
|
@@ -1,6 +1,7 @@
|
|
|
import React, {
|
|
|
FC, memo, useEffect, useRef, useState,
|
|
|
} from 'react';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
export const AlertType = {
|
|
|
WARNING: 'warning',
|
|
|
@@ -23,6 +24,7 @@ type ClosableTextInputProps = {
|
|
|
}
|
|
|
|
|
|
const ClosableTextInput: FC<ClosableTextInputProps> = memo((props: ClosableTextInputProps) => {
|
|
|
+ const { t } = useTranslation();
|
|
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
const [currentAlertInfo, setAlertInfo] = useState<AlertInfo | null>(null);
|
|
|
@@ -81,8 +83,10 @@ const ClosableTextInput: FC<ClosableTextInputProps> = memo((props: ClosableTextI
|
|
|
|
|
|
const alertType = currentAlertInfo.type != null ? currentAlertInfo.type : AlertType.ERROR;
|
|
|
const alertMessage = currentAlertInfo.message != null ? currentAlertInfo.message : 'Invalid value';
|
|
|
+ const alertTextStyle = alertType === AlertType.ERROR ? 'text-danger' : 'text-warning';
|
|
|
+ const translation = alertType === AlertType.ERROR ? 'Error' : 'Warning';
|
|
|
return (
|
|
|
- <p className="text-danger text-center mt-1">{alertType}: {alertMessage}</p>
|
|
|
+ <p className={`${alertTextStyle} text-center mt-1`}>{t(translation)}: {alertMessage}</p>
|
|
|
);
|
|
|
};
|
|
|
|