]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/twitch-bot/Commands.js
tracker items as svg
[alttp.git] / resources / js / components / twitch-bot / Commands.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Table } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
5
6 import Command from './Command';
7
8 const Commands = ({
9         channel,
10         onEditCommand,
11         onRemoveCommand,
12 }) => {
13         const { t } = useTranslation();
14
15         return channel.chat_commands ?
16                 <Table>
17                         <thead>
18                                 <tr>
19                                         <th>{t('twitchBot.commandName')}</th>
20                                         <th>{t('twitchBot.commandRestriction')}</th>
21                                         <th>{t('twitchBot.commandType')}</th>
22                                         <th className="text-end">{t('general.actions')}</th>
23                                 </tr>
24                         </thead>
25                         <tbody>
26                                 {Object.entries(channel.chat_commands).map(([name, settings]) =>
27                                         <Command
28                                                 key={name}
29                                                 name={name}
30                                                 onEditCommand={onEditCommand}
31                                                 onRemoveCommand={onRemoveCommand}
32                                                 settings={settings}
33                                         />
34                                 )}
35                         </tbody>
36                 </Table>
37         : null;
38 };
39
40 Commands.propTypes = {
41         channel: PropTypes.shape({
42                 chat_commands: PropTypes.shape({
43                 }),
44         }),
45         onEditCommand: PropTypes.func,
46         onRemoveCommand: PropTypes.func,
47 };
48
49 export default Commands;