+
+
diff --git a/src/store/actions/addStatement.js b/src/store/actions/addStatement.js
index 7d705ae..a76b1dd 100644
--- a/src/store/actions/addStatement.js
+++ b/src/store/actions/addStatement.js
@@ -1,27 +1,6 @@
import types from '../actions_types';
-export const onAddStatementPublicFigureSelection = id => ({
- type: types.ADD_STATEMENT_PUBLIC_FIGURE_SELECTION,
- id,
-});
-export const onAddStatementSubjectSelection = id => ({
- type: types.ADD_STATEMENT_SUBJECT_SELECTION,
- id,
-});
-export const onAddStatementPositionSelection = id => ({
- type: types.ADD_STATEMENT_POSITION_SELECTION,
- id,
-});
-
-export const onAddStatementUpdateEvidenceUrl = url => ({
- type: types.ADD_STATEMENT_UPDATE_EVIDENCE_URL,
- url,
-});
-export const onAddStatementUpdateEvidenceFile = file => ({
- type: types.ADD_STATEMENT_UPDATE_EVIDENCE_FILE,
- file,
-});
-
-export const onAddStatementValidate = () => ({
- type: types.ADD_STATEMENT_VALIDATE,
+export const onAddStatementValidate = newStatement => ({
+ type: types.ADD_STATEMENT_VALIDATE,
+ payload: { ...newStatement },
});
diff --git a/src/store/actions_types.js b/src/store/actions_types.js
index 89ad2d1..b922f4f 100644
--- a/src/store/actions_types.js
+++ b/src/store/actions_types.js
@@ -1,11 +1,6 @@
export default {
ENTITY_ACCESS: 'ENTITY_ACCESS',
ENTITY_READ: 'ENTITY_READ',
- ADD_STATEMENT_NEXT_STEP: 'ADD_STATEMENT_NEXT_STEP',
- ADD_STATEMENT_PUBLIC_FIGURE_SELECTION: 'ADD_STATEMENT_PUBLIC_FIGURE_SELECTION',
- ADD_STATEMENT_SUBJECT_SELECTION: 'ADD_STATEMENT_SUBJECT_SELECTION',
- ADD_STATEMENT_POSITION_SELECTION: 'ADD_STATEMENT_POSITION_SELECTION',
- ADD_STATEMENT_UPDATE_EVIDENCE_URL: 'ADD_STATEMENT_UPDATE_EVIDENCE_URL',
- ADD_STATEMENT_UPDATE_EVIDENCE_FILE: 'ADD_STATEMENT_UPDATE_EVIDENCE_FILE',
ADD_STATEMENT_VALIDATE: 'ADD_STATEMENT_VALIDATE',
+ STATEMENT_POST_BEGIN: 'STATEMENT_POST_BEGIN',
};
diff --git a/src/store/index.js b/src/store/index.js
index a991abc..6eb80ef 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -8,7 +8,7 @@ import createHashHistory from 'history/lib/createHashHistory';
import createMemoryHistory from 'history/lib/createMemoryHistory';
import rootSaga from './sagas';
-import { entitiesReducer, addStatementReducer } from './reducers';
+import { entitiesReducer } from './reducers';
// Build history
const createHistory = isClientSide() ? createHashHistory : createMemoryHistory;
@@ -22,7 +22,6 @@ const initialState = isClientSide() ? window.__INITIAL_STATE__ : {};
const reducer = combineReducers({
routing: routerReducer,
entities: entitiesReducer,
- addStatement: addStatementReducer,
});
// MIDDLEWARE
diff --git a/src/store/reducers/addStatement.js b/src/store/reducers/addStatement.js
deleted file mode 100644
index 2c9726b..0000000
--- a/src/store/reducers/addStatement.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import {
- assoc, compose, not, allPass, prop, isNil, either, complement,
-} from 'ramda';
-import actionsTypes from '../actions_types';
-
-const initialState = {
- publicFigureId: null,
- subjectId: null,
- positionId: null,
- statementDate: null,
- evidenceUrl: null,
- evidenceFile: null,
- quote: null,
- note: null,
- tags: [],
-};
-
-const isPublicFigureChosen = compose(not, isNil, prop('publicFigureId'));
-const isSubjectChosen = compose(not, isNil, prop('publicFigureId'));
-const isPositionChosen = compose(not, isNil, prop('publicFigureId'));
-const isStatementComplete = allPass([
- compose(not, isNil, prop('statementDate')),
- compose(not, isNil, prop('quote')),
- compose(not, isNil, prop('statementDate')),
- either(
- compose(not, isNil, prop('evidenceUrl')),
- compose(not, isNil, prop('evidenceFile')),
- ),
-]);
-
-/* eslint-disable no-unused-vars */
-const isPublicFigureMissing = complement(isPublicFigureChosen);
-const isSubjectMissing = complement(isSubjectChosen);
-const isPositionMissing = complement(isPositionChosen);
-const isStatementIncomplete = complement(isStatementComplete);
-
-export const addStatementReducer = (state = initialState, action) => {
- switch (action.type) {
- case actionsTypes.ADD_STATEMENT_PUBLIC_FIGURE_SELECTION: return assoc('publicFigureId', action.id, state);
- case actionsTypes.ADD_STATEMENT_SUBJECT_SELECTION: return assoc('subjectId', action.id, state);
- case actionsTypes.ADD_STATEMENT_POSITION_SELECTION: return assoc('positionId', action.id, state);
- case actionsTypes.ADD_STATEMENT_UPDATE_EVIDENCE_URL: return assoc('evidenceUrl', action.url, state);
- case actionsTypes.ADD_STATEMENT_UPDATE_EVIDENCE_FILE: return assoc('evidenceFile', action.file, state);
- default: return state;
- }
-};
diff --git a/src/store/reducers/index.js b/src/store/reducers/index.js
index 63f1bc7..78fffab 100644
--- a/src/store/reducers/index.js
+++ b/src/store/reducers/index.js
@@ -1,2 +1,2 @@
export * from './entities';
-export * from './addStatement';
+
diff --git a/src/store/sagas/apiSaga.js b/src/store/sagas/apiSaga.js
index b0b2e5b..86b9749 100644
--- a/src/store/sagas/apiSaga.js
+++ b/src/store/sagas/apiSaga.js
@@ -42,18 +42,4 @@ function* fetchEntityIfNeeded(action) {
export function* watchEntityAccess() {
yield* takeEvery(actionsTypes.ENTITY_ACCESS, fetchEntityIfNeeded);
}
-function* fetchPositionsOfSubject(action) {
- if (action.id) {
- // Call API
- const response = yield call(getPositions, action.id);
- // Error actions
-
- // Success actions
- yield put({ type: actionsTypes.ENTITY_READ, data: response.data });
- }
-}
-
-export function* watchSubjectSelection() {
- yield* takeEvery(actionsTypes.ADD_STATEMENT_SUBJECT_SELECTION, fetchPositionsOfSubject);
-}
diff --git a/src/store/sagas/index.js b/src/store/sagas/index.js
index a64b305..da6be4f 100644
--- a/src/store/sagas/index.js
+++ b/src/store/sagas/index.js
@@ -1,9 +1,9 @@
-import { watchEntityAccess, watchSubjectSelection } from './apiSaga';
-
+import { watchEntityAccess } from './apiSaga';
+import { watchStatementValidation } from './postStatement';
export default function* rootSaga() {
yield [
watchEntityAccess(),
- watchSubjectSelection(),
+ watchStatementValidation(),
];
}
diff --git a/src/store/sagas/postStatement.js b/src/store/sagas/postStatement.js
new file mode 100644
index 0000000..446cbcb
--- /dev/null
+++ b/src/store/sagas/postStatement.js
@@ -0,0 +1,21 @@
+import { takeEvery } from 'redux-saga';
+import { call, put } from 'redux-saga/effects';
+import actionsTypes from '../actions_types';
+import { postStatement } from 'api/debats';
+
+function* postNewStatement(action) {
+ yield put({ type: actionsTypes.STATEMENT_POST_BEGIN, payload: action.payload });
+
+ // Gérer d'abord les transferts de fichier sur un ID de transation
+
+ const response = yield call(postStatement);
+
+ // Error actions
+
+ // Success actions
+ yield put({ type: actionsTypes.STATEMENT_POST_SUCCESS, payload: action.payload });
+}
+
+export function* watchStatementValidation() {
+ yield* takeEvery(actionsTypes.ADD_STATEMENT_VALIDATE, postNewStatement);
+}