You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
// import { toast } from "react-toastify"; |
|
|
|
const initialState = { |
|
loading: false, |
|
error: null, |
|
list: [], |
|
info: null, |
|
sum: null, |
|
checkEmpty: false, |
|
isVerified: null, |
|
}; |
|
export default function userFactor(state = initialState, action) { |
|
let { type, data, message } = action; |
|
switch (type) { |
|
case "userFactor/list": |
|
const checkEmpty = data.filter( |
|
(item) => item.condition === 2 && item.product.productType === (1 || 3) |
|
); |
|
return { |
|
...state, |
|
loading: false, |
|
list: data, |
|
checkEmpty: checkEmpty.length > 0 ? false : true, |
|
error: null, |
|
}; |
|
case "userFactor/info": |
|
return { ...state, loading: false, info: data, error: null }; |
|
case "userFactor/update": |
|
console.log("userFactor/update"); |
|
// toast.success("درخواست شما با موفقیت انجام شد."); |
|
return { ...state, loading: false, error: null }; |
|
case "userFactor/add": |
|
// toast.success("درخواست شما با موفقیت انجام شد."); |
|
return { ...state, loading: false, error: null, sum: data.payPrice }; |
|
case "userFactor/delete": |
|
return { ...state, loading: false, error: null }; |
|
case "userFactor/payment": |
|
window.location.replace(data); |
|
return { ...state, loading: false, error: null, isVerified: false }; |
|
case "userFactor/verify": |
|
return { ...state, loading: false, error: null, isVerified: true }; |
|
case "userFactor/loading": |
|
return { ...state, loading: true }; |
|
case "userFactor/error": |
|
console.log("error"); |
|
// toast.error(data.message); |
|
return { ...state, loading: false, error: data.message }; |
|
default: |
|
return state; |
|
} |
|
}
|
|
|