Advertisement
Guest User

Untitled

a guest
Feb 9th, 2018
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.75 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import _ from "lodash"
  3. import "./App.css";
  4.  
  5. class App extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. employees: [
  10. {
  11. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  12. name : "Jerry Seinfeld",
  13. emp_id : "914037",
  14. position : "Chief Financial Officer",
  15. department : "Head Office",
  16. email : "seinfield@penske.com",
  17. },
  18. {
  19. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  20. name : "Cosmo Kramer",
  21. emp_id : "900345",
  22. position : "Operations Manager",
  23. department : "Operations",
  24. email : "kramer@penske.com",
  25. },
  26. {
  27. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  28. name : "George Costanza",
  29. emp_id : "833425",
  30. position : "Operations Trainee",
  31. department : "Operations",
  32. email : "costanza@penske.com",
  33. },
  34. {
  35. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  36. name : "Susan Ross",
  37. emp_id : "455326",
  38. position : "Operations Trainee",
  39. department : "Operations",
  40. email : "susan@penske.com",
  41. },
  42. {
  43. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  44. name : "Ruthie Cohen",
  45. emp_id : "123774",
  46. position : "Operations Trainee",
  47. department : "Operations",
  48. email : "cohen@penske.com",
  49. },
  50. {
  51. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  52. name : "Elaine Benes",
  53. emp_id : "87265",
  54. position : "Operations Trainee",
  55. department : "Operations",
  56. email : "Benes@penske.com",
  57. },
  58. {
  59. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  60. name : "George Steinbrenner ",
  61. emp_id : "866204",
  62. position : "Operations Trainee",
  63. department : "Operations",
  64. email : "steinbrener@penske.com",
  65. },
  66. {
  67. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  68. name : "Larry Charles",
  69. emp_id : "265674",
  70. position : "Operations Trainee",
  71. department : "Operations",
  72. email : "larry.charles@penske.com",
  73. },
  74. {
  75. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  76. name : "Larry Charles",
  77. emp_id : "279402",
  78. position : "Operations Trainee",
  79. department : "Operations",
  80. email : "larry.charles@penske.com",
  81. },
  82. {
  83. image : "https://www.shareicon.net/download/2015/09/24/106420_man_512x512.png",
  84. name : "Larry Charles",
  85. emp_id : "68292",
  86. position : "Operations Trainee",
  87. department : "Operations",
  88. email : "larry.charles@penske.com",
  89. },
  90. ],
  91. departments : [
  92. "Head Office",
  93. "Operations",
  94. ],
  95. positions : [
  96. "Chief Financial Officer",
  97. "Operations Trainee",
  98. "Operations Manager"
  99. ],
  100. emp_name : "",
  101. emp_id : "",
  102. department : 0,
  103. position : 0,
  104. };
  105. }
  106.  
  107. render() {
  108. let _this = this, data = this.state.employees;
  109.  
  110. if(!_.isEmpty(_this.state.emp_name)){
  111. data = _.filter(data, obj => obj.name.toLowerCase().indexOf(_this.state.emp_name.toLowerCase()) > -1);
  112. }
  113. if(!_.isEmpty(_this.state.emp_id)){
  114. data = _.filter(data, obj => obj.emp_id.toLowerCase().indexOf(_this.state.emp_id.toLowerCase()) > -1);
  115. }
  116. if(!_.isEmpty(_this.state.department)){
  117. data = _.filter(data, obj => obj.department == _this.state.department);
  118. }
  119. if(!_.isEmpty(_this.state.position)){
  120. data = _.filter(data, obj => obj.position == _this.state.position);
  121. }
  122. // if(!_.isEmpty(_this.state.emp_name) && ! _.isEmpty(_this.state.department) && ! _.isEmpty(_this.state.position)){
  123. //
  124. // }
  125. return (
  126. <div className="App">
  127. <header
  128. style={{
  129. height: 50,
  130. display: "flex",
  131. flexDirection: "row",
  132. flex: 1,
  133. justifyContent: "center",
  134. alignItems: "center"
  135. }}
  136. >
  137. <div
  138. style={{
  139. fontSize: 24,
  140. display: "inline",
  141. flex: 0.3,
  142. textAlign: "left"
  143. }}
  144. >
  145. <i class="fa fa-bars" /> PENSKE
  146. </div>
  147. <div
  148. style={{
  149. flexDirection: "row",
  150. flex: 0.5,
  151. justifyContent: "center",
  152. alignItems: "center",
  153. display: "inline",
  154. textAlign: "center"
  155. }}
  156. >
  157. <span className="App-title">
  158. NORTH STAR MOTORS <i class="fa fa-chevron-down" />
  159. </span>
  160. </div>
  161. <div
  162. className="App-title"
  163. style={{
  164. flex: 0.2,
  165. textAlign: "right",
  166. display: "flex",
  167. justifyContent: "flex-end",
  168. alignItems: "center"
  169. }}
  170. >
  171. <div
  172. style={{
  173. width: 24,
  174. height: 24,
  175. borderRadius: 12,
  176. backgroundColor: "#9c3d6b",
  177. color: "#fff",
  178. fontSize: 12,
  179. textAlign: "center",
  180. display: "flex",
  181. justifyContent: "center",
  182. alignItems: "center",
  183. marginRight: 5
  184. }}
  185. >
  186. <span>VJ</span>
  187. </div>
  188. <span
  189. style={{
  190. marginRight: 5
  191. }}
  192. >
  193. Jean Valjean
  194. </span>{" "}
  195. <i class="fa fa-chevron-down" />
  196. </div>
  197. </header>
  198. <div
  199. style={{
  200. flex: 1,
  201. display: "flex",
  202. height: 40,
  203. backgroundColor: "#891f59",
  204. justifyContent: "flex-start",
  205. alignItems: "center",
  206. color: "#fff",
  207. paddingLeft: 40
  208. }}
  209. >
  210. <span
  211. style={{
  212. marginRight: 10
  213. }}
  214. >
  215. Employees
  216. </span>
  217. <span>142 Employees</span>
  218. </div>
  219. <div
  220. style={{
  221. display: "flex",
  222. flex: 1,
  223. flexDirection: "row",
  224. padding: 15
  225. }}
  226. >
  227. <div
  228. style={{
  229. width: 300
  230. }}
  231. >
  232. <span>Filters</span>
  233. <div
  234. style={{
  235. marginBottom: 15,
  236. marginTop: 15
  237. }}
  238. >
  239. <labe
  240. for="name"
  241. style={{
  242. display: "block",
  243. width: "100%"
  244. }}
  245. >
  246. Name
  247. </labe>
  248. <input
  249. type="text"
  250. name="name"
  251. id="name"
  252. placeholder="Employee Name"
  253. style={{
  254. display: "block",
  255. width: "100%"
  256. }}
  257. value={this.state.emp_name}
  258. onChange={function (event) {
  259. _this.setState({
  260. emp_name : event.target.value
  261. })
  262. }}
  263. />
  264. </div>
  265. <div
  266. style={{
  267. marginBottom: 15,
  268. marginTop: 15
  269. }}
  270. >
  271. <labe
  272. for="emp_id"
  273. style={{
  274. display: "block"
  275. }}
  276. >
  277. Employee ID
  278. </labe>
  279. <input
  280. name="emp_id"
  281. id="emp_id"
  282. style={{
  283. display: "block",
  284. width: "100%"
  285. }}
  286. value={this.state.emp_id}
  287. onChange={function (event) {
  288. _this.setState({
  289. emp_id : event.target.value
  290. })
  291. }}
  292. />
  293. </div>
  294. <div
  295. style={{
  296. marginBottom: 15,
  297. marginTop: 15
  298. }}
  299. >
  300. <labe
  301. for="department"
  302. style={{
  303. display: "block"
  304. }}
  305. >
  306. Department
  307. </labe>
  308. <select
  309. name="department"
  310. id="department"
  311. placeholder="Choice"
  312. style={{
  313. display: "block",
  314. width: "100%"
  315. }}
  316. onChange={function (event) {
  317. _this.setState({
  318. department : event.target.value
  319. })
  320. }}
  321. >
  322. <option value="0">Choice</option>
  323. {this.state.departments.map(function (item) {
  324. return <option value={item} selected={_this.state.department == item}>{item}</option>
  325. })}
  326. </select>
  327. </div>
  328. <div
  329. style={{
  330. marginBottom: 15,
  331. marginTop: 15
  332. }}
  333. >
  334. <label
  335. for="position"
  336. style={{
  337. display: "block"
  338. }}
  339. >
  340. Position
  341. </label>
  342. <select
  343. name="position"
  344. id="position"
  345. placeholder="Choice"
  346. style={{
  347. display: "block",
  348. width: "100%"
  349. }}
  350. onChange={function (event) {
  351. _this.setState({
  352. position : event.target.value
  353. })
  354. }}
  355. >
  356. <option value="0">Choice</option>
  357. {this.state.positions.map(function (item) {
  358. return <option value={item} selected={_this.state.position == item}>{item}</option>
  359. })}
  360. </select>
  361. </div>
  362. </div>
  363. <div>
  364. <table>
  365. <thead>
  366. <tr>
  367. <th>Image</th>
  368. <th>Name</th>
  369. <th>Employee ID</th>
  370. <th>Position</th>
  371. <th>Department</th>
  372. <th>Email</th>
  373. </tr>
  374. </thead>
  375. <tbody>
  376. {data.map(function (item) {
  377. return <tr>
  378. <td><img src={item.image} alt="" style={{
  379. width : 32,
  380. height : 32,
  381. borderRadius: 16,
  382. backgroundColor : "#000fff",
  383. }}/></td>
  384. <td>{item.name}</td>
  385. <td>{item.emp_id}</td>
  386. <td>{item.position}</td>
  387. <td>{item.department}</td>
  388. <td>{item.email}</td>
  389. </tr>
  390. })}
  391. </tbody>
  392. </table>
  393. </div>
  394. </div>
  395. </div>
  396. );
  397. }
  398. }
  399.  
  400. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement