X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftournament%2FDiscordForm.js;h=d896504c60bab62d6c0617d68ccc8e34fcdf1c51;hb=147c5f43c5d41fa18e82edb6651fe5a37c789353;hp=f9eba93e516615f08437c302b3ea5070bb801a8b;hpb=f446d5bcf3b87bd9443a060e27e9c0601c96fbb9;p=alttp.git diff --git a/resources/js/components/tournament/DiscordForm.js b/resources/js/components/tournament/DiscordForm.js index f9eba93..d896504 100644 --- a/resources/js/components/tournament/DiscordForm.js +++ b/resources/js/components/tournament/DiscordForm.js @@ -2,10 +2,11 @@ import axios from 'axios'; import { withFormik } from 'formik'; import PropTypes from 'prop-types'; import React from 'react'; -import { Button, Col, Form, Row } from 'react-bootstrap'; +import { Button, Form } from 'react-bootstrap'; import { withTranslation } from 'react-i18next'; import toastr from 'toastr'; +import DiscordChannelSelect from '../common/DiscordChannelSelect'; import laravelErrorsToFormik from '../../helpers/laravelErrorsToFormik'; import i18n from '../../i18n'; import yup from '../../schema/yup'; @@ -16,11 +17,26 @@ const DiscordForm = ({ handleChange, handleSubmit, touched, + tournament, values, }) =>
{i18n.t('tournaments.discordSettings')} + + + {i18n.t('tournaments.discordRoundCategory')} + + + {i18n.t('tournaments.discordRoundTemplate')} @@ -42,15 +58,21 @@ const DiscordForm = ({ DiscordForm.propTypes = { errors: PropTypes.shape({ + round_category: PropTypes.string, round_template: PropTypes.string, }), handleBlur: PropTypes.func, handleChange: PropTypes.func, handleSubmit: PropTypes.func, touched: PropTypes.shape({ + round_category: PropTypes.bool, round_template: PropTypes.bool, }), + tournament: PropTypes.shape({ + discord: PropTypes.string, + }), values: PropTypes.shape({ + round_category: PropTypes.string, round_template: PropTypes.string, }), }; @@ -59,11 +81,12 @@ export default withFormik({ displayName: 'DiscordForm', enableReinitialize: true, handleSubmit: async (values, actions) => { - const { round_template } = values; + const { round_category, round_template } = values; const { setErrors } = actions; const { tournament } = actions.props; try { await axios.post(`/api/tournaments/${tournament.id}/discord-settings`, { + round_category, round_template, }); toastr.success(i18n.t('tournaments.discordSettingsSuccess')); @@ -75,9 +98,11 @@ export default withFormik({ } }, mapPropsToValues: ({ tournament }) => ({ + round_category: tournament.discord_round_category || '', round_template: tournament.discord_round_template || '', }), validationSchema: yup.object().shape({ + round_category: yup.string(), round_template: yup.string(), }), })(withTranslation()(DiscordForm));