parent
0dc00156ee
commit
f30b8cf7a9
@ -0,0 +1,43 @@ |
||||
import { actionTypes } from '../state/modals' |
||||
import { Modal } from '../types' |
||||
|
||||
interface Action { |
||||
type: string |
||||
payload: any |
||||
} |
||||
|
||||
export interface ModalState { |
||||
modals: Modal[], |
||||
toasters: string[], |
||||
focusModal: Modal, |
||||
focusToaster: string |
||||
} |
||||
|
||||
const ModalInitialState: ModalState = { |
||||
modals: [], |
||||
toasters: [], |
||||
focusModal: { |
||||
hide: true, |
||||
title: '', |
||||
message: '', |
||||
okLabel: '', |
||||
okFn: () => {}, |
||||
cancelLabel: '', |
||||
cancelFn: () => {} |
||||
}, |
||||
focusToaster: '' |
||||
} |
||||
|
||||
export const modalReducer = (state: ModalState = ModalInitialState, action: Action) => { |
||||
switch (action.type) { |
||||
case actionTypes.setModal: |
||||
state.modals.push(action.payload) |
||||
return { ...state } |
||||
} |
||||
return { |
||||
modals: state.modals, |
||||
toasters: state.toasters, |
||||
focusModal: state.focusModal, |
||||
focusToaster: state.focusToaster |
||||
} |
||||
} |
@ -0,0 +1,11 @@ |
||||
|
||||
export interface Modal { |
||||
hide?: boolean |
||||
title: string |
||||
// eslint-disable-next-line no-undef
|
||||
message: string | JSX.Element |
||||
okLabel: string |
||||
okFn: () => void |
||||
cancelLabel: string |
||||
cancelFn: () => void |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue