mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-30 23:26:40 +07:00
17 lines
365 B
TypeScript
17 lines
365 B
TypeScript
import { ERROR_LITERAL } from '~/constants/errors';
|
|
import { has } from 'ramda';
|
|
import { useMemo } from 'react';
|
|
|
|
export const useTranslatedError = (error: string | undefined) => {
|
|
return useMemo(() => {
|
|
if (!error) {
|
|
return '';
|
|
}
|
|
|
|
if (!has(error, ERROR_LITERAL)) {
|
|
return error;
|
|
}
|
|
|
|
return ERROR_LITERAL[error];
|
|
}, [error]);
|
|
};
|