X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftournament%2FSettingsDialog.js;h=46fbfd87ecae299ec5aef94bddebbf71c691af9b;hb=e1ecc76c1c6d527502d6576ee19be06df2a15bb7;hp=9cecb14a70dcfcfcdcb2c62798457fc052288968;hpb=43da6b2ec78774e7b045a09c68af39717b5f5dbc;p=alttp.git diff --git a/resources/js/components/tournament/SettingsDialog.js b/resources/js/components/tournament/SettingsDialog.js index 9cecb14..46fbfd8 100644 --- a/resources/js/components/tournament/SettingsDialog.js +++ b/resources/js/components/tournament/SettingsDialog.js @@ -1,11 +1,15 @@ import axios from 'axios'; import PropTypes from 'prop-types'; import React from 'react'; -import { Button, Modal } from 'react-bootstrap'; +import { Button, Col, Modal, Row } from 'react-bootstrap'; import { withTranslation } from 'react-i18next'; import toastr from 'toastr'; +import DiscordForm from './DiscordForm'; +import DiscordSelect from '../common/DiscordSelect'; +import Icon from '../common/Icon'; import ToggleSwitch from '../common/ToggleSwitch'; +import Tournament from '../../helpers/Tournament'; import i18n from '../../i18n'; const open = async tournament => { @@ -44,32 +48,100 @@ const unlock = async tournament => { } }; +const setDiscord = async (tournament, guild_id) => { + try { + await axios.post(`/api/tournaments/${tournament.id}/discord`, { guild_id }); + toastr.success(i18n.t('tournaments.discordSuccess')); + } catch (e) { + toastr.error(i18n.t('tournaments.discordError')); + } +}; + +const settings = async (tournament, params) => { + try { + await axios.post(`/api/tournaments/${tournament.id}/settings`, params); + toastr.success(i18n.t('tournaments.settingsSuccess')); + } catch (e) { + toastr.error(i18n.t('tournaments.settingsError')); + } +}; + +const inviteUrl = 'https://discordapp.com/oauth2/authorize?client_id=951113702839549982&scope=bot'; + const SettingsDialog = ({ onHide, show, tournament, }) => - + {i18n.t('tournaments.settings')} -
- {i18n.t('tournaments.open')} - value ? open(tournament) : close(tournament)} - value={tournament.accept_applications} - /> -
-
- {i18n.t('tournaments.locked')} - value ? lock(tournament) : unlock(tournament)} - value={tournament.locked} - /> -
+ + + {Tournament.hasSignup(tournament) ? +
+ {i18n.t('tournaments.open')} + value + ? open(tournament) : close(tournament)} + value={tournament.accept_applications} + /> +
+ : null} +
+ {i18n.t('tournaments.locked')} + value + ? lock(tournament) : unlock(tournament)} + value={tournament.locked} + /> +
+
+ {i18n.t('tournaments.showNumbers')} + + settings(tournament, { show_numbers: value })} + value={tournament.show_numbers} + /> +
+
+
+

{i18n.t('tournaments.discord')}

+ {!tournament.discord ? +
+ +
+ : null} +
+ setDiscord(tournament, value)} + value={tournament.discord} + /> +
+ + {tournament.discord ? + + + + : null} +