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.
40 lines
1001 B
40 lines
1001 B
import { toast } from "react-toastify"; |
|
|
|
const initialState = { |
|
loading: false, |
|
error: null, |
|
}; |
|
|
|
export default function audit(state = initialState, action) { |
|
let { type, data, message } = action; |
|
switch (type) { |
|
case "audit/revokeRole": |
|
toast.success(message, { autoClose: false }); |
|
return { |
|
...state, |
|
loading: false, |
|
error: null, |
|
}; |
|
case "audit/revokeTask": |
|
toast.success(message, { autoClose: false }); |
|
return { |
|
...state, |
|
loading: false, |
|
error: null, |
|
}; |
|
case "audit/check": |
|
toast.info(message, { autoClose: false }); |
|
return { |
|
...state, |
|
loading: false, |
|
error: null, |
|
}; |
|
case "audit/loading": |
|
return { ...state, loading: true }; |
|
case "audit/error": |
|
toast.error(data.message, { autoClose: !data.message.includes("!!") }); |
|
return { ...state, loading: false, error: data.message || message }; |
|
default: |
|
return state; |
|
} |
|
}
|
|
|