]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/rounds/EditForm.js
temporary user select
[alttp.git] / resources / js / components / rounds / EditForm.js
index 3d0d0b368ad0749008b4153327a5f85c37cc37ed..6472c842a27a28298a13298f2bb5ece02b7bf44a 100644 (file)
@@ -7,6 +7,7 @@ import { withTranslation } from 'react-i18next';
 import toastr from 'toastr';
 
 import SeedCodeInput from './SeedCodeInput';
+import UserSelect from '../common/UserSelect';
 import laravelErrorsToFormik from '../../helpers/laravelErrorsToFormik';
 import i18n from '../../i18n';
 import yup from '../../schema/yup';
@@ -77,6 +78,24 @@ const EditForm = ({
                                : null}
                        </Form.Group>
                </Row>
+               <Row>
+                       <Form.Group as={Col}>
+                               <Form.Label>{i18n.t('rounds.rolled_by')}</Form.Label>
+                               <Form.Control
+                                       as={UserSelect}
+                                       isInvalid={!!(touched.rolled_by && errors.rolled_by)}
+                                       name="rolled_by"
+                                       onBlur={handleBlur}
+                                       onChange={handleChange}
+                                       value={values.rolled_by || null}
+                               />
+                               {touched.rolled_by && errors.rolled_by ?
+                                       <Form.Control.Feedback type="invalid">
+                                               {i18n.t(errors.rolled_by)}
+                                       </Form.Control.Feedback>
+                               : null}
+                       </Form.Group>
+               </Row>
        </Modal.Body>
        <Modal.Footer>
                {onCancel ?
@@ -93,6 +112,7 @@ const EditForm = ({
 EditForm.propTypes = {
        errors: PropTypes.shape({
                code: PropTypes.arrayOf(PropTypes.string),
+               rolled_by: PropTypes.string,
                seed: PropTypes.string,
                title: PropTypes.string,
        }),
@@ -102,12 +122,14 @@ EditForm.propTypes = {
        onCancel: PropTypes.func,
        touched: PropTypes.shape({
                code: PropTypes.arrayOf(PropTypes.bool),
+               rolled_by: PropTypes.bool,
                seed: PropTypes.bool,
                title: PropTypes.bool,
        }),
        values: PropTypes.shape({
                code: PropTypes.arrayOf(PropTypes.string),
                game: PropTypes.string,
+               rolled_by: PropTypes.string,
                seed: PropTypes.string,
                title: PropTypes.string,
        }),
@@ -136,12 +158,14 @@ export default withFormik({
        mapPropsToValues: ({ round }) => ({
                code: round.code || [],
                game: round.game || 'mixed',
+               rolled_by: round.rolled_by || null,
                round_id: round.id,
                seed: round.seed || '',
                title: round.title || '',
        }),
        validationSchema: yup.object().shape({
                code: yup.array().of(yup.string()),
+               rolled_by: yup.string(),
                seed: yup.string().url(),
                title: yup.string(),
        }),