parent
f0a4d8c9dd
commit
ea74009e7d
10 changed files with 51 additions and 73 deletions
@ -0,0 +1,12 @@ |
|||||||
|
const alert = { |
||||||
|
toast: |
||||||
|
(data = {}) => |
||||||
|
async (dispatch) => |
||||||
|
await dispatch({ type: "alert/toast", data }), |
||||||
|
confirm: |
||||||
|
(data = {}) => |
||||||
|
async (dispatch) => |
||||||
|
await dispatch({ type: "alert/confirm", data }), |
||||||
|
}; |
||||||
|
|
||||||
|
export default alert; |
@ -1 +1,2 @@ |
|||||||
export { default as components } from "./components"; |
export { default as components } from "./components"; |
||||||
|
export { default as alert } from "./alert"; |
||||||
|
@ -1,15 +0,0 @@ |
|||||||
import { INFO_ALERT, TOAST_ALERT } from "./types"; |
|
||||||
|
|
||||||
export const infoAlert = (data) => (dispatch) => { |
|
||||||
dispatch({ |
|
||||||
type: INFO_ALERT, |
|
||||||
data: data, |
|
||||||
}); |
|
||||||
}; |
|
||||||
|
|
||||||
export const toastAlert = (data) => (dispatch) => { |
|
||||||
dispatch({ |
|
||||||
type: TOAST_ALERT, |
|
||||||
data: data, |
|
||||||
}); |
|
||||||
}; |
|
@ -1,2 +0,0 @@ |
|||||||
export const INFO_ALERT = "INFO_ALERT"; |
|
||||||
export const TOAST_ALERT = "TOAST_ALERT"; |
|
@ -1 +1,2 @@ |
|||||||
export { default as components } from "./components"; |
export { default as components } from "./components"; |
||||||
|
export { default as alert } from "./alert"; |
||||||
|
@ -1,10 +0,0 @@ |
|||||||
import modalReducer from "./modalReducer"; |
|
||||||
import toastReducer from "./toastReducer"; |
|
||||||
import { combineReducers } from "redux"; |
|
||||||
|
|
||||||
const rootReducer = combineReducers({ |
|
||||||
modalReducer: modalReducer, |
|
||||||
toastReducer: toastReducer, |
|
||||||
}); |
|
||||||
|
|
||||||
export default rootReducer; |
|
@ -1,34 +0,0 @@ |
|||||||
import { INFO_ALERT, TOAST_ALERT } from "../actions/types"; |
|
||||||
import Swal from "sweetalert2"; |
|
||||||
|
|
||||||
const initialState = {}; |
|
||||||
|
|
||||||
const toastReducer = (state = initialState, action) => { |
|
||||||
const { type, data } = action; |
|
||||||
switch (type) { |
|
||||||
case TOAST_ALERT: |
|
||||||
Swal.fire({ |
|
||||||
icon: data.icon, |
|
||||||
title: data.title, |
|
||||||
showCloseButton: data.showCloseButton, |
|
||||||
toast: data.toast, |
|
||||||
position: data.position, |
|
||||||
showConfirmButton: data.showConfirmButton, |
|
||||||
timer: data.timer, |
|
||||||
timerProgressBar: data.timerProgressBar, |
|
||||||
customClass: { |
|
||||||
title: data.customClass.title, |
|
||||||
closeButton: data.customClass.closeButton, |
|
||||||
popup: data.customClass.popup, |
|
||||||
footer: data.customClass.footer, |
|
||||||
}, |
|
||||||
}); |
|
||||||
return { |
|
||||||
...state, |
|
||||||
}; |
|
||||||
default: |
|
||||||
return state; |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
export default toastReducer; |
|
Loading…
Reference in new issue