File tree Expand file tree Collapse file tree 4 files changed +48
-44
lines changed Expand file tree Collapse file tree 4 files changed +48
-44
lines changed Original file line number Diff line number Diff line change 11import { useEffect } from 'react'
22import { useDispatch , useSelector } from 'react-redux'
3- import { fetchKeyData } from '../util/slices/keyDataSlicer '
3+ import { fetchKeyData } from '../util/redux/keyDataReducer '
44import { RootState } from '../util/store'
55
66const useFetchKeyData = ( ) => {
77 const dispatch = useDispatch ( )
8- const keyData = useSelector ( ( state : RootState ) => state . keyData )
8+ const keyData = useSelector ( ( state : RootState ) => state . keyData . data )
99
1010 useEffect ( ( ) => {
1111 dispatch ( fetchKeyData ( ) )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import faculties from './facultyReducer'
1717import summaries from './summaryReducer'
1818import reformAnswers from './reformAnswerReducer'
1919import monitoring from './facultyMonitoringReducer'
20+ import keyData from './keyDataReducer'
2021
2122export default combineReducers ( {
2223 form,
@@ -36,4 +37,5 @@ export default combineReducers({
3637 summaries,
3738 reformAnswers,
3839 monitoring,
40+ keyData,
3941} )
Original file line number Diff line number Diff line change 1+ import callBuilder from '../apiConnection'
2+ interface State {
3+ data : any ;
4+ pending ?: boolean ;
5+ error ?: boolean ;
6+ }
7+
8+ interface Action {
9+ type : string ;
10+ response ?: any ;
11+ }
12+
13+ export const fetchKeyData = ( ) => {
14+ const route = '/keyData'
15+ const prefix = 'GET_KEY_DATA'
16+ return callBuilder ( route , prefix )
17+ }
18+
19+ export default ( state : State = { data : null } , action : Action ) => {
20+ switch ( action . type ) {
21+ case 'GET_KEY_DATA_ATTEMPT' :
22+ return {
23+ ...state ,
24+ pending : true ,
25+ error : false ,
26+ }
27+ case 'GET_KEY_DATA_SUCCESS' :
28+ return {
29+ ...state ,
30+ data : action . response ,
31+ pending : false ,
32+ error : false ,
33+ }
34+ case 'GET_KEY_DATA_FAILURE' :
35+ return {
36+ ...state ,
37+ data : [ ] ,
38+ pending : false ,
39+ error : true ,
40+ }
41+ default :
42+ return state
43+ }
44+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments