X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Fresults%2FReportForm.js;h=35b7e0fddab94a55d5773c1c15b5cbc0371f4d8d;hb=52424eef6a48c5019d48cea8e38daa8375660b29;hp=942869da7123c36b160ef76368c3877f2032bbee;hpb=a4260a00251cef4ad806c9d5c44d4c444d6ab831;p=alttp.git
diff --git a/resources/js/components/results/ReportForm.js b/resources/js/components/results/ReportForm.js
index 942869d..35b7e0f 100644
--- a/resources/js/components/results/ReportForm.js
+++ b/resources/js/components/results/ReportForm.js
@@ -8,7 +8,7 @@ import toastr from 'toastr';
import LargeCheck from '../common/LargeCheck';
import laravelErrorsToFormik from '../../helpers/laravelErrorsToFormik';
-import { findResult } from '../../helpers/Participant';
+import { findResult } from '../../helpers/User';
import { formatTime, parseTime } from '../../helpers/Result';
import i18n from '../../i18n';
import yup from '../../schema/yup';
@@ -66,19 +66,39 @@ const ReportForm = ({
: null}
-
-
- {i18n.t('results.comment')}
-
-
-
+
+ {i18n.t('results.vod')}
+
+ {touched.vod && errors.vod ?
+
+ {i18n.t(errors.vod)}
+
+ :
+
+ {i18n.t('results.vodNote')}
+
+ }
+
+
+ {i18n.t('results.comment')}
+
+
{onCancel ?
@@ -97,6 +117,7 @@ ReportForm.propTypes = {
comment: PropTypes.string,
forfeit: PropTypes.string,
time: PropTypes.string,
+ vod: PropTypes.string,
}),
handleBlur: PropTypes.func,
handleChange: PropTypes.func,
@@ -109,11 +130,13 @@ ReportForm.propTypes = {
comment: PropTypes.bool,
forfeit: PropTypes.bool,
time: PropTypes.bool,
+ vod: PropTypes.bool,
}),
values: PropTypes.shape({
comment: PropTypes.string,
forfeit: PropTypes.bool,
time: PropTypes.string,
+ vod: PropTypes.string,
}),
};
@@ -121,16 +144,17 @@ export default withFormik({
displayName: 'ReportForm',
enableReinitialize: true,
handleSubmit: async (values, actions) => {
- const { comment, forfeit, participant_id, round_id, time } = values;
+ const { comment, forfeit, round_id, time, user_id, vod } = values;
const { setErrors } = actions;
const { onCancel } = actions.props;
try {
await axios.post('/api/results', {
comment,
forfeit,
- participant_id,
round_id,
time: parseTime(time) || 0,
+ user_id,
+ vod,
});
toastr.success(i18n.t('results.reportSuccess'));
if (onCancel) {
@@ -143,14 +167,15 @@ export default withFormik({
}
}
},
- mapPropsToValues: ({ participant, round }) => {
- const result = findResult(participant, round);
+ mapPropsToValues: ({ round, user }) => {
+ const result = findResult(user, round);
return {
comment: result && result.comment ? result.comment : '',
forfeit: result ? !!result.forfeit : false,
- participant_id: participant.id,
round_id: round.id,
time: result && result.time ? formatTime(result) : '',
+ user_id: user.id,
+ vod: result && result.vod ? result.vod : '',
};
},
validationSchema: yup.object().shape({
@@ -160,5 +185,6 @@ export default withFormik({
is: false,
then: yup.string().required().time(),
}),
+ vod: yup.string().url(),
}),
})(withTranslation()(ReportForm));