1
- /* eslint-disable no-param-reassign */
2
1
import { createSlice } from '@reduxjs/toolkit' ;
3
2
4
3
export const LOADING = 'loading' ;
@@ -17,27 +16,39 @@ const slice = createSlice({
17
16
org : null ,
18
17
} ,
19
18
reducers : {
20
- fetchTabDenied : ( state , { payload } ) => {
21
- state . courseId = payload . courseId ;
22
- state . courseStatus = DENIED ;
23
- } ,
24
- fetchTabFailure : ( state , { payload } ) => {
25
- state . courseId = payload . courseId ;
26
- state . courseStatus = FAILED ;
27
- } ,
28
- fetchTabRequest : ( state , { payload } ) => {
29
- state . courseId = payload . courseId ;
30
- state . courseStatus = LOADING ;
31
- } ,
32
- fetchTabSuccess : ( state , { payload } ) => {
33
- state . courseId = payload . courseId ;
34
- state . targetUserId = payload . targetUserId ;
35
- state . tabs = payload . tabs ;
36
- state . courseStatus = LOADED ;
37
- state . courseTitle = payload . courseTitle ;
38
- state . courseNumber = payload . courseNumber ;
39
- state . org = payload . org ;
40
- } ,
19
+ fetchTabDenied : ( state , { payload } ) => (
20
+ {
21
+ ...state ,
22
+ courseId : payload . courseId ,
23
+ courseStatus : DENIED ,
24
+ }
25
+ ) ,
26
+ fetchTabFailure : ( state , { payload } ) => (
27
+ {
28
+ ...state ,
29
+ courseId : payload . courseId ,
30
+ courseStatus : FAILED ,
31
+ }
32
+ ) ,
33
+ fetchTabRequest : ( state , { payload } ) => (
34
+ {
35
+ ...state ,
36
+ courseId : payload . courseId ,
37
+ courseStatus : LOADING ,
38
+ }
39
+ ) ,
40
+ fetchTabSuccess : ( state , { payload } ) => (
41
+ {
42
+ ...state ,
43
+ courseId : payload . courseId ,
44
+ targetUserId : payload . targetUserId ,
45
+ tabs : payload . tabs ,
46
+ courseStatus : LOADED ,
47
+ courseTitle : payload . courseTitle ,
48
+ courseNumber : payload . courseNumber ,
49
+ org : payload . org ,
50
+ }
51
+ ) ,
41
52
} ,
42
53
} ) ;
43
54
0 commit comments