X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FReportForm.js;h=942869da7123c36b160ef76368c3877f2032bbee;hb=8d97d023740e438361e659c6e133418e33343178;hp=943aac39ff059c016bef1f49e9fff978fc75d60e;hpb=920f11ddfeb2175e4e1556886773dcd044c6085b;p=alttp.git diff --git a/resources/js/components/results/ReportForm.js b/resources/js/components/results/ReportForm.js index 943aac3..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, @@ -122,8 +145,8 @@ export default withFormik({ }, mapPropsToValues: ({ participant, round }) => { const result = findResult(participant, round); - console.log(result); return { + comment: result && result.comment ? result.comment : '', forfeit: result ? !!result.forfeit : false, participant_id: participant.id, round_id: round.id, @@ -131,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,