import type { ISetting } from '@rocket.chat/core-typings'; import { Box, Callout } from '@rocket.chat/fuselage'; import { GenericModal } from '@rocket.chat/ui-client'; import { useSetModal } from '@rocket.chat/ui-contexts'; import { useCallback } from 'react'; import { Trans, useTranslation } from 'react-i18next'; export const useShowSettingAlerts = () => { const { t, i18n } = useTranslation(); const setModal = useSetModal(); const showAlerts = useCallback( (persistedSettingsWithAlert: ISetting[]) => { return new Promise((resolve) => { setModal( { resolve(true); setModal(null); }} onCancel={() => { resolve(false); return setModal(null); }} onClose={() => { resolve(false); return setModal(null); }} > {persistedSettingsWithAlert.map(({ _id, i18nLabel, alert }) => { if (!alert) { return null; } const labelText = (i18n.exists(i18nLabel) && t(i18nLabel)) || (i18n.exists(_id) && t(_id)) || i18nLabel || _id; return ( {labelText} , strong: , br:
, ul:
    , li:
  • , }} /> ); })} , ); }); }, [t, i18n, setModal], ); return showAlerts; };