Skip to content

Commit

Permalink
Refactor: modal body and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
MHMighani committed May 24, 2022
1 parent e4b028b commit e5d529b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
13 changes: 3 additions & 10 deletions client/src/components/common/modal.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import BootModal from "react-bootstrap/Modal";

function CustomModal({ title, show, body, handleConfirm, handleClose }) {
function CustomModal({ title, show, body, handleClose, footer }) {
return (
<BootModal show={show} onHide={handleClose}>
<BootModal.Header closeButton>
<BootModal.Title>{title}</BootModal.Title>
</BootModal.Header>

<BootModal.Footer>
<button className="btn btn-success" onClick={handleConfirm}>
تایید
</button>
<button className="btn btn-danger" onClick={handleClose}>
انصراف
</button>
</BootModal.Footer>
{body && <BootModal.Body>{body}</BootModal.Body>}
{footer && <BootModal.Footer>{footer}</BootModal.Footer>}
</BootModal>
);
}
Expand Down
12 changes: 12 additions & 0 deletions client/src/hooks/useDeleteMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@ const useDeleteMsgModal = (handleConfirm) => {
handleDelMsgClose();
};

const modalFooter = (
<>
<button className="btn btn-success" onClick={handleMessageConfirm}>
تایید
</button>
<button className="btn btn-danger" onClick={handleDelMsgClose}>
انصراف
</button>
</>
);

const modalBody = (
<CustomModal
title={title}
handleClose={handleDelMsgClose}
show={messageDisplay}
handleConfirm={handleMessageConfirm}
footer={modalFooter}
/>
);

Expand Down

0 comments on commit e5d529b

Please sign in to comment.