Created
May 9, 2020 14:31
-
-
Save casdidier/f08e117ae6016cd8cbda6d8577595a27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Modal, Button } from 'react-bootstrap'; | |
import Room from './Room.js'; | |
import RoomUpdate from './RoomUpdate'; | |
const RoomModal = (props) => { | |
const isEdit = props.editionMode; | |
const roomUpdate = ({title, action}) => { | |
return (<Room | |
saveButton={{ display: 'none' }} | |
displayModal2={props.displayModal1} | |
formName={"MODAL_FORM"}> | |
<div style={{ float: "right" }}> | |
<Button | |
type="button" | |
variant="outline-secondary" | |
style={{ marginRight: '1px' }} | |
onClick={() => props.displayModal1()}> | |
close | |
</Button> | |
<Button | |
variant="primary" | |
type="submit" >{action} | |
</Button> | |
</div> | |
</Room> | |
)} | |
const roomCreate = ({title, action}) => { | |
return (<RoomUpdate | |
saveButton={{ display: 'none' }} | |
displayModal2={props.displayModal1} | |
formName={"MODAL_FORM"}> | |
<div style={{ float: "right" }}> | |
<Button | |
type="button" | |
variant="outline-secondary" | |
style={{ marginRight: '1px' }} | |
onClick={() => props.displayModal1()}> | |
close | |
</Button> | |
<Button | |
variant="primary" | |
type="submit" >{action} | |
</Button> | |
</div> | |
</RoomUpdate>) | |
} | |
const room = ({title, action, isEdit}) => { | |
return ( | |
<div> | |
{isEdit ? roomUpdate({title, action})() : roomCreate({title, action})()} | |
</div> | |
)} | |
const modal = ({title, action, isEdit}) => { | |
return (<Modal show={props.showModal} | |
onHide={() => props.displayModal1()} | |
aria-labelledby="contained-modal-title"> | |
<Modal.Header closeButton> | |
<Modal.Title id="contained-modal-title">{title}</Modal.Title> | |
</Modal.Header> | |
<Modal.Body> | |
{room({title, action, isEdit})} | |
</Modal.Body> | |
</Modal>) | |
} | |
return ( | |
<div> | |
{/* {isEdit | |
? modal({title: 'Edit current room', action: 'Save changes', isEdit}) | |
: modal({title: "Add a new room", action: "Create room", isEdit})} */} | |
modal({title: "Add a new room", action: "Create room", isEdit}) | |
</div> | |
); | |
} | |
export default RoomModal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
missing { } around modal line 78