unioil-loyalty-rn-app/app/redux/reducers/AlertReducer.js

29 lines
673 B
JavaScript

import { TYPE_OPEN_ALERT, TYPE_CLOSE_ALERT } from "../types";
const initialState = {
open: false,
title: "",
body: "",
noCB: undefined,
yesCB: undefined,
yesText: "",
noText: "",
yesButtonOnly: false,
noButtonOnly: false,
theme: undefined
}
export function alertReducer(state = initialState, action) {
switch(action.type) {
case TYPE_OPEN_ALERT:
return Object.assign({}, state, {
...action.payload
});
case TYPE_CLOSE_ALERT:
return Object.assign({}, state, {
...initialState
});
default:
return state
}
}