stream-chat-react
Version:
React components to create chat conversations or livestream style chat
30 lines (29 loc) • 1.38 kB
JavaScript
import { useMemo } from 'react';
import React from 'react';
import { useTranslationContext } from '../../../context';
export const CommandItem = (props) => {
const { t } = useTranslationContext();
const { entity } = props;
const knownArgsTranslations = useMemo(() => ({
ban: t('ban-command-args'),
giphy: t('giphy-command-args'),
mute: t('mute-command-args'),
unban: t('unban-command-args'),
unmute: t('unmute-command-args'),
}), [t]);
const knownDescriptionTranslations = useMemo(() => ({
ban: t('ban-command-description'),
giphy: t('giphy-command-description'),
mute: t('mute-command-description'),
unban: t('unban-command-description'),
unmute: t('unmute-command-description'),
}), [t]);
return (React.createElement("div", { className: 'str-chat__slash-command' },
React.createElement("span", { className: 'str-chat__slash-command-header' },
React.createElement("strong", null, entity.name),
' ',
entity.args && (knownArgsTranslations[entity.name ?? ''] ?? t(entity.args))),
React.createElement("br", null),
React.createElement("span", { className: 'str-chat__slash-command-description' }, entity.description &&
(knownDescriptionTranslations[entity.name ?? ''] ?? t(entity.description)))));
};