File size: 537 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import type { ModalData } from '../../interfaces/index.js'
import { HIDE_MODAL, SHOW_MODAL } from '../actions/modal.js'
export type ModalInState = (ModalData & { show: true }) | { show: false }
export const modalReducer = (
state: ModalInState = { show: false },
action: {
type: string
data: ModalData
},
): ModalInState => {
switch (action.type) {
case SHOW_MODAL: {
return {
...action.data,
show: true,
}
}
case HIDE_MODAL: {
return { show: false }
}
default:
return state
}
}
|