@trellixio/roaster-coffee
Version:
Beans' product component library
43 lines (41 loc) • 859 B
JavaScript
function handleCloseModal(modal) {
modal.props.onClose?.();
}
function modalReducer(state, action) {
switch (action.type) {
case "OPEN": {
return {
...action.modal
};
}
case "CLOSE": {
handleCloseModal(state);
return null;
}
default: {
return state;
}
}
}
function getModalProviderFooterProps(props) {
if (!props) {
return { footerProps: {}, modalProps: {} };
}
const { onCancel, onConfirm, closeOnConfirm, closeOnCancel, cancelProps, confirmProps, labels, ...others } = props;
return {
footerProps: {
onCancel,
onConfirm,
closeOnConfirm,
closeOnCancel,
cancelProps,
confirmProps,
labels
},
modalProps: {
...others
}
};
}
export { getModalProviderFooterProps, modalReducer };
//# sourceMappingURL=reducer.js.map