parent
506e95e44a
commit
e90cea120d
19 changed files with 156 additions and 62 deletions
@ -0,0 +1,20 @@ |
||||
interface addVOD { |
||||
type: "userProduct/addVOD"; |
||||
data: any; |
||||
} |
||||
|
||||
interface error{ |
||||
type : "userProduct/error" |
||||
data : undefined |
||||
} |
||||
|
||||
interface loading{ |
||||
type : "userProduct/loading" |
||||
data : undefined |
||||
} |
||||
|
||||
|
||||
type UserProductAction = addVOD | error | loading; |
||||
|
||||
|
||||
export default UserProductAction; |
@ -0,0 +1,20 @@ |
||||
import { toast } from "react-toastify"; |
||||
import {UserProductAction} from '../actions-type'; |
||||
const initialState = { |
||||
loading: false, |
||||
error: null, |
||||
}; |
||||
export default function userFactor(state = initialState, action : UserProductAction) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "userProduct/addVOD": |
||||
return { ...state, loading: false, error: null }; |
||||
case "userProduct/loading": |
||||
return { ...state, loading: true }; |
||||
case "userProduct/error": |
||||
toast.error(data.message); |
||||
return { ...state, loading: false, error: data.message }; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Loading…
Reference in new issue