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 = ({
type: ADD_SOLUTION,
payload: response.data,
});
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
......@@ -103,13 +101,10 @@ export const addDocument = ({
};
const response = await axios.post('/api/v1/documents/', formData, config);
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: ADD_DOCUMENT,
payload: response.data,
});
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
......
import React, { Component } from 'react';
import { Modal, Button, Form, Input, TextArea, Icon } from 'semantic-ui-react';
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 {
constructor(props) {
......@@ -19,9 +19,9 @@ class AddSolutionForm extends Component {
const corrected = false;
const accepted = false;
const note = '';
// const solution = (this.props.homeworks.solutions[this.props.homeworks.solutions.length - 1]).id;
// TODO: undefined
const solution = 1;
let solution = 1;
if((this.props.homeworks.solutions[this.props.homeworks.solutions.length - 1]) !== undefined)
solution = (this.props.homeworks.solutions[this.props.homeworks.solutions.length - 1]).id;
return (
<Modal
open={this.state.showModal}
......@@ -93,4 +93,5 @@ export default connect(mapStateToProps, {
writeSolution,
writeSolutionFile,
addDocument,
clearWrite,
})(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 = {
task: '',
......@@ -16,6 +16,8 @@ export default (state = INITIAL_STATE, action) => {
return { ...state, [action.target]: action.payload };
case GET_SOLUTIONS:
return { ...state, solutions: action.payload };
case CLEAR_WRITE:
return INITIAL_STATE;
default:
return state;
}
......
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