Advertisement
Guest User

Untitled

a guest
May 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {Component} from 'react';
  2. import './index.scss';
  3. import {showing} from "services/api";
  4. import {cinema} from "services/cinema";
  5. import Page from "components/Page";
  6. import {groupBy} from "ramda";
  7. import avatarImg from "assets/images/avatar.png";
  8. import {Link} from "react-router-dom";
  9. import Dialog from 'material-ui/Dialog';
  10. import FlatButton from 'material-ui/FlatButton';
  11. import RaisedButton from 'material-ui/RaisedButton';
  12. import moment from 'moment';
  13.  
  14. const styles = {
  15.   flatbtn: {
  16.     fontSize: 20,
  17.   },
  18. };
  19.  
  20. class Repertoire extends Component {
  21.  
  22.     state = {
  23.         showings: [],
  24.     cinema: {},
  25.     open: false,
  26.     }
  27.  
  28.   constructor(props) {
  29.     super(props)
  30.   }
  31.  
  32.   componentDidMount() {
  33.         showing
  34.       .allForCinema(cinema.current.id)
  35.             .then(response => {
  36.                 this.setState({
  37.                     showings: response.data,
  38.                 })
  39.             })
  40.   }
  41.  
  42.   handleOpen = () => {
  43.     this.setState({open: true});
  44.   };
  45.  
  46.   handleClose = () => {
  47.     this.setState({open: false});
  48.   };
  49.  
  50.   groupByMovie = groupBy((showing) => showing.movie.id)
  51.  
  52.   render() {
  53.     console.log(this.state)
  54.     const actions = [
  55.       <RaisedButton
  56.         label="Rezerwuj/ Kup bilet"
  57.         primary={true}
  58.         onClick={this.handleClose}
  59.         labelStyle={styles.flatbtn}
  60.       />,
  61.     ];
  62.  
  63.     return (
  64.             <Page>
  65.         <div className="repertoire">
  66.                     <section className="hero is-light">
  67.                         <div className="hero-body">
  68.                             <div className="container">
  69.                                 <h1 className="title">W dniu</h1>
  70.                             </div>
  71.                         </div>
  72.                     </section>
  73.  
  74.                     <div className="container">
  75.             <div className="list">
  76.               {
  77.                 this.state.showings
  78.                   .map((showing, key) =>
  79.                     <div key={showing.id} className="tile  hvr-grow">
  80.                                             <div className="has-text-centered">
  81.                                                 <img src={showing.movie.imgURL} />
  82.                                             </div>
  83.                                             <div className="movie-info">
  84.                                                 <div>{showing.movie.title}</div>                                               
  85.                                                 <div>12 lat</div>                                              
  86.                                                 <div>{showing.movie.groups.map((g, i) => `${g.label}${i+1 !== showing.movie.groups.length ? ',':''} `)}</div>                                              
  87.                                                 <div>{showing.movie.runTime} min</div>                                             
  88.                                             </div>
  89.                                             <div className="showings-info">
  90.                         <Link to={'/repertoire/reservation/' + showing.id} >
  91.                                                 <b>10:10</b>
  92.                         </Link>
  93.                                                 <b>13:30</b>
  94.                                                 <b>19:50</b>
  95.                           <button onClick={this.handleOpen}>Click me!</button>
  96.                         <Dialog
  97.                           actions={actions}
  98.                           modal={false}
  99.                           open={this.state.open}
  100.                           onRequestClose={this.handleClose}
  101.                         >
  102.                           <div className="movie-info-wrapper">
  103.                             <div className="movie-info-img">
  104.                               <div className="imgimg">
  105.                                 <img className="poster" src={showing.movie.imgURL} />
  106.                               </div>
  107.                             </div>
  108.                             <div className="movie-info-txt">
  109.                               <h2>{showing.movie.title}</h2>
  110.                               {showing.movie.groups.map((group) =>
  111.                                 <p key={group.id} className="types">{group.label}</p>
  112.                               )}
  113.                               <p>Czas trwania: {showing.movie.runTime} min. </p>
  114.                               <p>Od lat: {showing.movie.age} </p>
  115.                               <p>Produkcja: {showing.movie.country}</p>
  116.                               <p>.............................................</p>
  117.                               <p className="headingsp2">Kino:</p>
  118.                               <p className="types2">{cinema.current.name}</p>
  119.                               <p className="headingsp2">Data:</p>
  120.                               <p className="types2">{moment(showing.screeningStart).format("YYYY-MM-DD  hh:mm")}</p>
  121.                             </div>
  122.                           </div>
  123.                         </Dialog>
  124.                       </div>
  125.                   </div>
  126.                 )
  127.               }
  128.              
  129.             </div>
  130.           </div>
  131.          
  132.          
  133.         </div>
  134.       </Page>
  135.     )
  136.   }
  137. }
  138.  
  139. export default Repertoire;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement