Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 KB | None | 0 0
  1. import React,{Component} from 'react'
  2. import Footer from '../Footer/Footer'
  3. import Header from '../Header'
  4. import SubNav from '../SubNav'
  5. import Details from './Details'
  6. import {Link} from 'react-router-dom'
  7. import {Configurations} from '../AppConfig'
  8.  
  9. class Project extends Component{
  10.  
  11. state = {
  12. projectInfo: null,
  13. reloadHandlerActive: false,
  14. projectID : this.props.match.params.id,
  15. projectName: "",
  16. topProjectInfo: [],
  17. images: []
  18. }
  19.  
  20. createImages = (project) =>{
  21. let Images = Object.values(project.images),
  22. ImagesURI = Images.map((img, index)=>{
  23. if( img.includes('Desarrollos.jpg') || img.includes('Home.jpg') || img.includes('H.jpg') ){
  24. return null
  25. }
  26. return project.path+img
  27. })
  28. ImagesURI = ImagesURI.filter(function (e) { //Clear null values
  29. return e != null;
  30. })
  31. return ImagesURI
  32. }
  33.  
  34. reloadHandler = (id) =>{
  35. const {createImages} = this
  36. fetch(Configurations.API.projectInfo(id))
  37. .then((result)=>{return result.json() })
  38. .then((project)=>{
  39. if(project === "error"){
  40. alert("Error")
  41. }else{
  42. this.setState({
  43. projectInfo: project,
  44. images: createImages(project)
  45. },function(){
  46. document.getElementsByClassName("nav-button")[0].click()
  47. })
  48. }
  49. })
  50. }
  51.  
  52. componentWillMount(){
  53. const {createImages} = this
  54. fetch(Configurations.API.projectInfo(this.state.projectID))
  55. .then((result)=>{return result.json() })
  56. .then((project)=>{
  57. if(project === "error"){
  58. alert("Error")
  59. }else{
  60. this.setState({
  61. projectInfo: project,
  62. images: createImages(project)
  63. },function(){
  64. window.initDogma()
  65. })
  66. }
  67. })
  68. }
  69.  
  70. componentDidMount(){
  71. window.onload = window.initShit()
  72. }
  73.  
  74. render(){
  75. const {projectInfo,images} = this.state
  76. console.log(projectInfo)
  77.  
  78. if(!projectInfo){
  79. return(<h1>. . .</h1>)
  80. }
  81. return(
  82. <div >
  83. <Header />
  84. <SubNav reloadHandler={this.reloadHandler} />
  85. <div className="content full-height no-padding">
  86.  
  87. <div className="fixed-info-container">
  88. <Link to="/portfolio"><button className="goBackBtn">Desarrollos</button></Link>
  89. <h3>{projectInfo.project.project}</h3>
  90. <div className="separator" />
  91. <div className="clearfix" />
  92. <p>
  93. {projectInfo.project.address}
  94. </p>
  95. <span className="project-status">{projectInfo.project.status}</span>
  96. <h4>Características</h4>
  97. <Details price={projectInfo.project.price} features={projectInfo.project.features} />
  98. <Link className=" btn anim-button trans-btn transition fl-l" to={"/contact/?project="+projectInfo.id}>
  99. <span>Informes</span>
  100. <i className="fa fa-eye" />
  101. </Link>
  102. </div>
  103.  
  104.  
  105. {/* fixed-info-container end*/}
  106. {/* resize-carousel-holder*/}
  107. <div className="resize-carousel-holder vis-info gallery-horizontal-holder">
  108. {/* gallery_horizontal*/}
  109. <div
  110. id="gallery_horizontal"
  111. className="gallery_horizontal owl_carousel"
  112. >
  113. {
  114. images.map((img,index)=>{
  115. return (
  116. <div key={index}className="horizontal_item">
  117. <div className="zoomimage">
  118. <img src={img} className="intense" alt="" />
  119. <i className="fa fa-expand" />
  120. </div>
  121. <img src={img} alt="" />
  122. <div className="show-info">
  123. <span>Info</span>
  124. <div className="tooltip-info">
  125. <h5>Imagen de muestra</h5>
  126. <p>
  127. Imagen del desarrollo
  128. </p>
  129. </div>
  130. </div>
  131. </div>
  132. )
  133. })
  134. }
  135. </div>
  136. {/* resize-carousel-holder*/}
  137. {/* navigation */}
  138. <div className="customNavigation">
  139. <a href="/" className="prev-slide transition">
  140. <i className="fa fa-angle-left" />
  141. </a>
  142. <a href="/" className="next-slide transition">
  143. <i className="fa fa-angle-right" />
  144. </a>
  145. </div>
  146. {/* navigation end*/}
  147. </div>
  148. {/* gallery_horizontal end*/}
  149. </div>
  150. <Footer />
  151. </div>
  152. )
  153. }
  154. }
  155. export default Project
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement