Skip to content
Snippets Groups Projects
Commit eab21544 authored by Sandor Bereczki's avatar Sandor Bereczki
Browse files

Added ClearWrite action, solution fix

parent cee7815d
No related branches found
No related tags found
No related merge requests found
...@@ -77,8 +77,6 @@ export const addSolution = ({ ...@@ -77,8 +77,6 @@ export const addSolution = ({
type: ADD_SOLUTION, type: ADD_SOLUTION,
payload: response.data, payload: response.data,
}); });
} else {
alert('Mentés nem sikerült!');
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
...@@ -103,13 +101,10 @@ export const addDocument = ({ ...@@ -103,13 +101,10 @@ export const addDocument = ({
}; };
const response = await axios.post('/api/v1/documents/', formData, config); const response = await axios.post('/api/v1/documents/', formData, config);
if (response.data.id) { if (response.data.id) {
alert('Sikeres mentés!');
dispatch({ dispatch({
type: ADD_DOCUMENT, type: ADD_DOCUMENT,
payload: response.data, payload: response.data,
}); });
} else {
alert('Mentés nem sikerült!');
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Modal, Button, Form, Input, TextArea, Icon } from 'semantic-ui-react'; import { Modal, Button, Form, Input, TextArea, Icon } from 'semantic-ui-react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { addSolution, writeSolution, writeSolutionFile, addDocument } from '../../actions/homework'; import { addSolution, writeSolution, writeSolutionFile, addDocument, clearWrite } from '../../actions/homework';
class AddSolutionForm extends Component { class AddSolutionForm extends Component {
constructor(props) { constructor(props) {
...@@ -19,9 +19,9 @@ class AddSolutionForm extends Component { ...@@ -19,9 +19,9 @@ class AddSolutionForm extends Component {
const corrected = false; const corrected = false;
const accepted = false; const accepted = false;
const note = ''; const note = '';
// const solution = (this.props.homeworks.solutions[this.props.homeworks.solutions.length - 1]).id; let solution = 1;
// TODO: undefined if((this.props.homeworks.solutions[this.props.homeworks.solutions.length - 1]) !== undefined)
const solution = 1; solution = (this.props.homeworks.solutions[this.props.homeworks.solutions.length - 1]).id;
return ( return (
<Modal <Modal
open={this.state.showModal} open={this.state.showModal}
...@@ -93,4 +93,5 @@ export default connect(mapStateToProps, { ...@@ -93,4 +93,5 @@ export default connect(mapStateToProps, {
writeSolution, writeSolution,
writeSolutionFile, writeSolutionFile,
addDocument, addDocument,
clearWrite,
})(AddSolutionForm); })(AddSolutionForm);
import { WRITE_SOLUTION, WRITE_SOLUTION_FILE, GET_SOLUTIONS } from '../actions/types'; import { WRITE_SOLUTION, WRITE_SOLUTION_FILE, GET_SOLUTIONS, CLEAR_WRITE } from '../actions/types';
const INITIAL_STATE = { const INITIAL_STATE = {
task: '', task: '',
...@@ -16,6 +16,8 @@ export default (state = INITIAL_STATE, action) => { ...@@ -16,6 +16,8 @@ export default (state = INITIAL_STATE, action) => {
return { ...state, [action.target]: action.payload }; return { ...state, [action.target]: action.payload };
case GET_SOLUTIONS: case GET_SOLUTIONS:
return { ...state, solutions: action.payload }; return { ...state, solutions: action.payload };
case CLEAR_WRITE:
return INITIAL_STATE;
default: default:
return state; return state;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment