Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <Panel onClick={this.onSelectRooms} className={this.state.selectedRooms.includes() ? 'bg-success' : ''}>
  2.  
  3. export default class ExportReportRoomSelectionModal extends React.Component {
  4.  
  5. constructor(props) {
  6. super(props);
  7.  
  8. const roomOrder = configContext.value.roomOrder;
  9.  
  10. this.state = {
  11. rooms: roomOrder,
  12. selectedRooms: []
  13. };
  14.  
  15. this.onSelectRooms = this.onSelectRooms.bind(this);
  16.  
  17. }
  18.  
  19. onSelectRooms = (e) => {
  20.  
  21. const { selectedRooms } = this.state;
  22. const { id } = e.target;
  23.  
  24. //remove roomId
  25.  
  26. if(selectedRooms.includes(id)) {
  27. this.setState({
  28. selectedRooms: selectedRooms.filter((name) => name !== id)
  29. });
  30.  
  31. //add roomId
  32. } else{
  33. this.setState({
  34. selectedRooms: [...selectedRooms, id]
  35. });
  36. }
  37. }
  38.  
  39.  
  40. render() {
  41.  
  42.  
  43. return (
  44. <Modal}>
  45. <Modal.Header closeButton>
  46. <Modal.Title>Print PDF</Modal.Title>
  47. </Modal.Header>
  48. <Modal.Body>
  49. <p>Number of rooms: {this.state.rooms.length}</p>
  50. <p>Rooms:</p>
  51.  
  52. <Grid fluid={true}>
  53. <Row className="show-grid">
  54. { this.state.rooms.map((name, i ) =>
  55.  
  56. <Col key={i}>
  57. <Panel onClick={this.onSelectRooms} className={this.state.selectedRooms.includes() ? 'bg-success' : ''}>
  58. <Panel.Heading id={name}>
  59. {name}
  60. </Panel.Heading>
  61. </Panel>
  62. </Col>
  63. )}
  64. </Row>
  65. </Grid>
  66.  
  67. </Modal.Body>
  68. <Modal.Footer>
  69.  
  70. </Modal>);
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement