X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fchat-bot-logs%2FItem.js;h=f50d078f27bda27666020367dfc81d14c93528af;hb=HEAD;hp=8340e4ed9df6097ce3d31cb8e77ee7677901d400;hpb=147c5f43c5d41fa18e82edb6651fe5a37c789353;p=alttp.git diff --git a/resources/js/components/chat-bot-logs/Item.js b/resources/js/components/chat-bot-logs/Item.js index 8340e4e..f50d078 100644 --- a/resources/js/components/chat-bot-logs/Item.js +++ b/resources/js/components/chat-bot-logs/Item.js @@ -4,12 +4,9 @@ import React from 'react'; import { ListGroup } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; -const getEntryDate = entry => { - const dateStr = moment(entry.created_at).fromNow(); - return entry.user - ? `${entry.user.username} ${dateStr}` - : dateStr; -}; +import { getUserName } from '../../helpers/User'; + +const getEntryDate = entry => moment(entry.created_at).fromNow(); const getEntryOrigin = (entry, t) => { return t('chatBotLog.origin.chatLog', { @@ -19,6 +16,29 @@ const getEntryOrigin = (entry, t) => { }); }; +const getEntryInfo = (entry, t) => { + if (entry.user && entry.category) { + return t('chatBotLog.info.userCat', { + category: t(`twitchBot.chatCategories.${entry.category}`), + date: getEntryDate(entry), + user: getUserName(entry.user), + }); + } + if (entry.category) { + return t('chatBotLog.info.cat', { + category: t(`twitchBot.chatCategories.${entry.category}`), + date: getEntryDate(entry), + }); + } + if (entry.user) { + return t('chatBotLog.info.user', { + date: getEntryDate(entry), + user: getUserName(entry.user), + }); + } + return getEntryDate(entry); +}; + const Item = ({ entry }) => { const { t } = useTranslation(); @@ -38,7 +58,7 @@ const Item = ({ entry }) => { className="text-muted" title={moment(entry.created_at).format('LLLL')} > - {getEntryDate(entry)} + {getEntryInfo(entry, t)} ;