Skip to content
Snippets Groups Projects
Commit 681d6971 authored by Bsandor453's avatar Bsandor453
Browse files

Refactor and fix homework validation

parent e1fbbb8c
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ class AddSolutionForm extends Component { ...@@ -33,6 +33,7 @@ class AddSolutionForm extends Component {
const sentences = this.props.taskdesc.split('\n'); const sentences = this.props.taskdesc.split('\n');
const note = ''; const note = '';
const disabledText = 'A határidő lejárt, további beadás nem lehetséges.'; const disabledText = 'A határidő lejárt, további beadás nem lehetséges.';
return ( return (
<Modal <Modal
open={this.state.showModal} open={this.state.showModal}
...@@ -99,19 +100,16 @@ class AddSolutionForm extends Component { ...@@ -99,19 +100,16 @@ class AddSolutionForm extends Component {
button={ button={
<Button <Button
disabled={ disabled={
name === '' || !name || !description ||
description === '' || (!file ? false : !allowedFileTypes.includes(file.type) ||
(file === '' ? false : file.size > (maxFileSize) * (1024 ** 2))
!allowedFileTypes.includes(file.type) ||
file.size > (maxFileSize) * (1024 ** 2)
)
} }
inverted inverted
color='green' color='green'
> >
<Icon name='checkmark' /> Beadás <Icon name='checkmark' /> Beadás
</Button> </Button>
} }
text='beadod az új megoldást, ami felülírja az előzőt' text='beadod az új megoldást, ami felülírja az előzőt'
onAccept={() => { onAccept={() => {
this.props.addSolution({ this.props.addSolution({
...@@ -126,7 +124,11 @@ class AddSolutionForm extends Component { ...@@ -126,7 +124,11 @@ class AddSolutionForm extends Component {
<Button <Button
inverted inverted
color='green' color='green'
disabled={(name === '' || description === '')} disabled={
!name || !description ||
(!file ? false : !allowedFileTypes.includes(file.type) ||
file.size > (maxFileSize) * (1024 ** 2))
}
onClick={() => { onClick={() => {
this.props.addSolution({ this.props.addSolution({
task, accepted, corrected, note, name, description, file, task, accepted, corrected, note, name, description, file,
......
...@@ -45,10 +45,7 @@ class ConfirmModal extends Component { ...@@ -45,10 +45,7 @@ class ConfirmModal extends Component {
<Button <Button
color='green' color='green'
inverted inverted
onClick={() => { onAccept(); onClick={() => { onAccept(); this.close(); }}
this.close();
}
}
> >
<Icon name='checkmark' /> Igen <Icon name='checkmark' /> Igen
</Button> </Button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment