Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. import React from "react"
  2. import * as firebase from 'firebase';
  3. import NavBarSignOut from '../navBar/navBarSignOut';
  4. import {Link,browserHistory} from 'react-router';
  5.  
  6.  
  7.  
  8.  
  9. class Candidiate extends React.Component{
  10. constructor(props){
  11. super(props);
  12. this.state = {
  13. myProfile : [],
  14. jobKeys : []
  15. }
  16. }
  17. componentDidMount(){
  18. const refRoot = firebase.database().ref();
  19. const rootRef = refRoot.child('jobs');
  20. rootRef.on('value',snapshot=>{
  21. var userObj = snapshot.val();
  22. console.log(userObj);
  23. let vm = this;
  24. let obj = [];
  25. let keys = [];
  26. Object.keys(userObj).forEach(function (key) {
  27. obj = userObj[key]
  28. keys.push(key);
  29. vm.state.myProfile.push(obj)
  30. vm.setState({ myProfile: vm.state.myProfile,
  31. jobKeys : keys
  32. })
  33. });
  34. })
  35. const apply = rootRef.child(this.state.jobKeys+'/appliers').on('value',snap=>{
  36. var apply = snap.val();
  37. console.log(apply);
  38. let a = [];
  39. Object.keys(apply).forEach(function (key){
  40. a = apply[key];
  41. console.log(a);
  42. this.setState({myProfile : this.state.a})
  43. })
  44. })
  45. }
  46.  
  47. render(){
  48. return firebase.auth().currentUser ? (
  49. <div>
  50. <NavBarSignOut />
  51. <center> <h1>Profile</h1> </center>
  52. {this.state.myProfile.map((data , index) => (
  53. <div key={index} className="container">
  54.  
  55. <table className="table">
  56. <thead >
  57. <tr>
  58. <th>Name</th>
  59. <th>Education</th>
  60. <th>Skills</th>
  61. <th>Email</th>
  62. <th>GPA</th>
  63. <th>Experience</th>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. <tr>
  68. <td>{data.sName}</td>
  69. <td>{data.education}</td>
  70. <td>{data.skills}</td>
  71. <td>{data.sEmail}</td>
  72. <td>{data.gpa}</td>
  73. <td>{data.experience}</td>
  74. </tr>
  75. </tbody>
  76. </table>
  77.  
  78. </div> ))}
  79. <Link to="student" className="btn btn-primary">
  80. Go Back student Panel
  81. </Link>
  82. </div>
  83. ) : ( <div>{browserHistory.push('login')}</div> )
  84. }
  85. }
  86. export default Candidiate;
  87.  
  88. {
  89. "jobs" : {
  90. "-KpdYaI_E5Vp39bkeFww" : {
  91. "appliers" : {
  92. "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2" : {
  93. "education" : "cma",
  94. "experience" : "not",
  95. "gpa" : "4",
  96. "sEmail" : "talha@gmail.com",
  97. "sId" : "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2",
  98. "sName" : "talha",
  99. "skills" : "finance"
  100. }
  101. },
  102. "companyName" : "panacloud",
  103. "education" : "",
  104. "email" : "pana@gmail.com",
  105. "jobTitle" : "",
  106. "skills" : "",
  107. "uid" : "CcyYpW5c3GOcU3ltBIpSSg9cnd33"
  108. },
  109. "-KpeKF86tqYdosIOJP8M" : {
  110. "appliers" : {
  111. "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2" : {
  112. "education" : "cma",
  113. "experience" : "not",
  114. "gpa" : "4",
  115. "sEmail" : "talha@gmail.com",
  116. "sId" : "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2",
  117. "sName" : "talha",
  118. "skills" : "finance"
  119. }
  120. },
  121. "companyName" : "ibm",
  122. "education" : "bcom",
  123. "email" : "ibm@gmail.com",
  124. "jobTitle" : "data entry ",
  125. "skills" : "english",
  126. "uid" : "TgrXg6Fx0WZFhmNHRY0nxsLxkbL2"
  127. },
  128. "-Kpeew-PmNnqEB6f4Q_g" : {
  129. "companyName" : "ibm",
  130. "education" : "bscs",
  131. "email" : "ibm@gmail.com",
  132. "jobTitle" : "front end",
  133. "skills" : "html , css ,js",
  134. "uid" : "TgrXg6Fx0WZFhmNHRY0nxsLxkbL2"
  135. }
  136. },
  137. "update Profile" : {
  138. "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2" : {
  139. "education" : "cma",
  140. "experience" : "not",
  141. "gpa" : "4",
  142. "sEmail" : "talha@gmail.com",
  143. "sId" : "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2",
  144. "sName" : "talha",
  145. "skills" : "finance"
  146. },
  147. "vGHLdbDPF1YcvFOwzULmc0uIQUF3" : {
  148. "education" : "fcma",
  149. "experience" : "no",
  150. "gpa" : "4",
  151. "sEmail" : "student@gmail.com",
  152. "sId" : "vGHLdbDPF1YcvFOwzULmc0uIQUF3",
  153. "sName" : "student",
  154. "skills" : "taxation"
  155. }
  156. },
  157. "user" : {
  158. "CcyYpW5c3GOcU3ltBIpSSg9cnd33" : {
  159. "typeOfUser" : "company",
  160. "uEmail" : "pana@gmail.com",
  161. "uName" : "panacloud",
  162. "uPassword" : "12345678"
  163. },
  164. "JfUXMVNDrnVcnOkn8tZ1LfUFf2P2" : {
  165. "typeOfUser" : "student",
  166. "uEmail" : "talha@gmail.com",
  167. "uName" : "talha",
  168. "uPassword" : "12345678"
  169. },
  170. "TgrXg6Fx0WZFhmNHRY0nxsLxkbL2" : {
  171. "typeOfUser" : "company",
  172. "uEmail" : "ibm@gmail.com",
  173. "uName" : "ibm",
  174. "uPassword" : "12345678"
  175. },
  176. "vGHLdbDPF1YcvFOwzULmc0uIQUF3" : {
  177. "typeOfUser" : "student",
  178. "uEmail" : "student@gmail.com",
  179. "uName" : "student",
  180. "uPassword" : "12345678"
  181. }
  182. }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement