import i18n from 'i18next';
import { getErrorMessageValue } from '../useMessageUtils';
import { messageAction } from '../sessionTypes';
import { getCommonDispatch } from '../commonDispatch';
export function dispatchApiError({ err, t, key, }) {
    const translate = t ?? i18n.t.bind(i18n);
    const value = getErrorMessageValue({ err, t: translate, key });
    getCommonDispatch()?.(messageAction({ value, type: 'error' }));
}
export function dispatchServerApiError({ err, t, }) {
    dispatchApiError({
        err,
        t,
        key: 'common',
    });
}
