1 import axios from 'axios';
2 import { withFormik } from 'formik';
3 import PropTypes from 'prop-types';
4 import React from 'react';
5 import { Button, Col, Form, Modal, Row } from 'react-bootstrap';
6 import { withTranslation } from 'react-i18next';
8 import i18n from '../../i18n';
9 import yup from '../../schema/yup';
20 <Form noValidate onSubmit={handleSubmit}>
23 <Form.Group as={Col} controlId="round.seed">
24 <Form.Label>{i18n.t('rounds.seed')}</Form.Label>
26 isInvalid={!!(touched.seed && errors.seed)}
29 onChange={handleChange}
30 placeholder="https://alttprpatch.synack.live/patcher.html?patch=https://sahasrahbot.s3.amazonaws.com/patch/DR_XXXXXXXXXXX.bps"
32 value={values.seed || ''}
34 {touched.seed && errors.seed ?
35 <Form.Control.Feedback type="invalid">
37 </Form.Control.Feedback>
44 <Button onClick={onCancel} variant="secondary">
45 {i18n.t('button.cancel')}
48 <Button type="submit" variant="primary">
49 {i18n.t('button.save')}
54 ReportForm.propTypes = {
55 errors: PropTypes.shape({
56 seed: PropTypes.string,
58 handleBlur: PropTypes.func,
59 handleChange: PropTypes.func,
60 handleSubmit: PropTypes.func,
61 onCancel: PropTypes.func,
62 touched: PropTypes.shape({
65 values: PropTypes.shape({
66 seed: PropTypes.string,
70 export default withFormik({
71 displayName: 'SeedForm',
72 enableReinitialize: true,
73 handleSubmit: async (values, actions) => {
74 const { round_id, seed } = values;
75 const { onCancel } = actions.props;
76 await axios.post(`/api/rounds/${round_id}/setSeed`, {
83 mapPropsToValues: ({ round }) => ({
85 seed: round.seed || '',
87 validationSchema: yup.object().shape({
88 seed: yup.string().required().url(),
90 })(withTranslation()(ReportForm));