X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftournament%2FSettingsDialog.js;h=46fbfd87ecae299ec5aef94bddebbf71c691af9b;hb=e1ecc76c1c6d527502d6576ee19be06df2a15bb7;hp=af4d664efe0d2f60c435e169c9a000a395b39bd6;hpb=f446d5bcf3b87bd9443a060e27e9c0601c96fbb9;p=alttp.git diff --git a/resources/js/components/tournament/SettingsDialog.js b/resources/js/components/tournament/SettingsDialog.js index af4d664..46fbfd8 100644 --- a/resources/js/components/tournament/SettingsDialog.js +++ b/resources/js/components/tournament/SettingsDialog.js @@ -9,6 +9,7 @@ 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 => { @@ -56,6 +57,15 @@ const setDiscord = async (tournament, guild_id) => { } }; +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 = ({ @@ -77,20 +87,30 @@ const SettingsDialog = ({ + {Tournament.hasSignup(tournament) ? +
+ {i18n.t('tournaments.open')} + value + ? open(tournament) : close(tournament)} + value={tournament.accept_applications} + /> +
+ : null}
- {i18n.t('tournaments.open')} + {i18n.t('tournaments.locked')} value - ? open(tournament) : close(tournament)} - value={tournament.accept_applications} + ? lock(tournament) : unlock(tournament)} + value={tournament.locked} />
- {i18n.t('tournaments.locked')} + {i18n.t('tournaments.showNumbers')} value - ? lock(tournament) : unlock(tournament)} - value={tournament.locked} + onChange={({ target: { value } }) => + settings(tournament, { show_numbers: value })} + value={tournament.show_numbers} />
@@ -137,6 +157,7 @@ SettingsDialog.propTypes = { accept_applications: PropTypes.bool, discord: PropTypes.string, locked: PropTypes.bool, + show_numbers: PropTypes.bool, }), };