I have a dialog message in a modal that asks the user to save changes if there is an attempt to navigate to another screen without saving.
It has 3 buttons (Save, Proceed without Saving, and Close). Obviously, the modal window looks exactly the same on all screens but the Save and Go back without Saving perform different actions depending on the screen.
I tried creating a separate Redux reducer for the modal but I learnt that you aren't allowed to store functions in Redux.
So my question is what is the recommended approach in a situation where you have the same modals in terms of UI but different in terms of the actions they perform?
I would really want to have it at the root level so that I can just dispatch an action and not be bothered with importing the modal to each component and controlling its state inside the component.
Here is an example of the action that I initially was planning to dispatch to show the modal
showModal: (state, { payload }) => {
state.modal.isOpen = true;
state.modal.header = payload.header;
state.modal.title = payload.title;
state.modal.btnText1 = payload.btnText1;
state.modal.btnText2 = payload.btnText2;
state.modal.btnText3 = payload.btnText3;
state.modal.btnAction1 = payload.btnAction1;
state.modal.btnAction2 = payload.btnAction2;
state.modal.btnAction3 = payload.btnAction3;
}