X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FReportForm.js;h=942869da7123c36b160ef76368c3877f2032bbee;hb=a4260a00251cef4ad806c9d5c44d4c444d6ab831;hp=28a757a78ed9326a916aa6f3f24a18b3f7fedda6;hpb=d3c484627e5923d4843420ba06dc33c79101e891;p=alttp.git diff --git a/resources/js/components/results/ReportForm.js b/resources/js/components/results/ReportForm.js index 28a757a..942869d 100644 --- a/resources/js/components/results/ReportForm.js +++ b/resources/js/components/results/ReportForm.js @@ -19,47 +19,63 @@ const ReportForm = ({ handleChange, handleSubmit, onCancel, + round, touched, values, }) =>
+ {!round.locked ? + + + {i18n.t('results.reportTime')} + + {touched.time && errors.time ? + + {i18n.t(errors.time)} + + : + + {parseTime(values.time) ? + i18n.t( + 'results.reportPreview', + { time: formatTime({ time: parseTime(values.time) })}, + ) + : null} + + } + + + {i18n.t('results.forfeit')} + + + + : null} - - {i18n.t('results.reportTime')} + + {i18n.t('results.comment')} - {touched.time && errors.time ? - - {i18n.t(errors.time)} - - : - - {parseTime(values.time) ? - i18n.t( - 'results.reportPreview', - { time: formatTime({ time: parseTime(values.time) })}, - ) - : null} - - } - - - {i18n.t('results.forfeit')} - @@ -78,6 +94,7 @@ const ReportForm = ({ ReportForm.propTypes = { errors: PropTypes.shape({ + comment: PropTypes.string, forfeit: PropTypes.string, time: PropTypes.string, }), @@ -85,11 +102,16 @@ ReportForm.propTypes = { handleChange: PropTypes.func, handleSubmit: PropTypes.func, onCancel: PropTypes.func, + round: PropTypes.shape({ + locked: PropTypes.bool, + }), touched: PropTypes.shape({ + comment: PropTypes.bool, forfeit: PropTypes.bool, time: PropTypes.bool, }), values: PropTypes.shape({ + comment: PropTypes.string, forfeit: PropTypes.bool, time: PropTypes.string, }), @@ -99,11 +121,12 @@ export default withFormik({ displayName: 'ReportForm', enableReinitialize: true, handleSubmit: async (values, actions) => { - const { forfeit, participant_id, round_id, time } = values; + const { comment, forfeit, participant_id, round_id, time } = values; const { setErrors } = actions; const { onCancel } = actions.props; try { await axios.post('/api/results', { + comment, forfeit, participant_id, round_id, @@ -123,6 +146,7 @@ export default withFormik({ mapPropsToValues: ({ participant, round }) => { const result = findResult(participant, round); return { + comment: result && result.comment ? result.comment : '', forfeit: result ? !!result.forfeit : false, participant_id: participant.id, round_id: round.id, @@ -130,6 +154,7 @@ export default withFormik({ }; }, validationSchema: yup.object().shape({ + comment: yup.string(), forfeit: yup.boolean().required(), time: yup.string().time().when('forfeit', { is: false,