ldc-com-app/ComApp/src/App/Store/Reducers/documents.js

24 lines
495 B
JavaScript
Raw Normal View History

import {INIT_DOCUMENTS} from '../Actions/actionType';
2022-12-28 16:32:30 +01:00
// Models
import {Document} from '../../../Database';
2022-12-28 16:32:30 +01:00
const initialState = [];
const reducer = (state = initialState, action) => {
switch (action.type) {
case INIT_DOCUMENTS: {
let docs = Document.getAll(action.directories);
if (docs.length === 0) {
return state;
}
return docs.filter(item => item.lang === action.lang);
}
2022-12-28 16:32:30 +01:00
default: {
return state;
2022-12-28 16:32:30 +01:00
}
}
2022-12-28 16:32:30 +01:00
};
export default reducer;