Open mkozhukharenko opened 8 years ago
думаю что вот этот кусок кода из src/modules/enrolments/view/MainInfo.jsx
const select = (state)=> {
return {
mainInfo: state.enrolments.view.mainInfo,
dictionaries: state.dictionaries
};
};
можно было бы написать по другому
import { createSelector } from 'reselect'
export const getVisibleTodos = createSelector(
[ (state) => state.enrolments.view.mainInfo,
(state) => state.dictionaries,
(state, ownProps) => ownProps.params.id] ],
(mainInfo, listOfDict, enrolId) => ({
decodedEnrolmnets: decodeOneEnrolment(mainInfo.data[enrolId], listOfDict)
})
)
как -то так Но это больше псевдокод чем работающий пример Чем лучше: 1) логику всю прописываем селекторе 2) не прокидываем ненужные пропсы в компонент
Single enrolment view
fetch data
GET /enrolments/{id}
Response example:
decode data
Some of filed need to be decoded with help of dictionaries. isState - 0 - false 1- true (Бюджет). isContract 1 true ((КонтракТ) isHostel 0 - 'не потреб. гуртож.', 1 - 'потреб. гуртож.' isPrivilege 0 - 'пільги відсутні', 1 - 'є пільги' departmentId - use
/api/departments?departmentTypeId=1
for this enrolmentTypeId - userapi/enrolments/types
for this isEducationStateisInterview
isOriginal - є оригінал чи немає
Pass to view
Create container and components for this. route for container -
enrolments/{id}/mainInfo
EnrolmentView render method will be like this:
Router will be like this:![](http://i.imgur.com/JcSp46m.png)
More info:![](http://i.imgur.com/w9iGxBS.png)
For future development (LOW PRIORITY)
It will be a separate task. get and show: