xonecas.io
366
Hc

hirenimble-challenge / commit 6cab602

Complete step 1 un-asthetically

xonecas2020-08-31 6cab602cc140849e36343081eb161f93fba4b0fe parent 510ba50

5 files changed

.gitignore+1−0
@@ -21,3 +21,4 @@
2121 npm-debug.log*
2222 yarn-debug.log*
2323 yarn-error.log*
24+.devcontainer
src/components/candidateListContent.js+3−25
@@ -1,33 +1,11 @@
11 import React from "react";
2-import moment from "moment";
2+import CandidateListItem from "./candidateListItem";
33
44 function CandidateListContent(props) {
55 const candidates = props.candidates;
6+
67 return candidates.map((candidate) => {
7- return (
8- <React.Fragment>
9- <tr key={candidate.id} id={candidate.id}>
10- <td>{candidate.name}</td>
11- <td>
12- {candidate.applications[0].new_status.color}
13- {candidate.applications[0].new_status.label}
14- </td>
15- <td>{candidate.applications.lengtd}</td>
16- <td>{moment(candidate.profile.updated).fromNow()}</td>
17- <td>{candidate.scorecard_count}</td>
18- <td>{candidate.profile.nimble_score}</td>
19- <td>{candidate.note_count}</td>
20- </tr>
21- {candidate.applications.map((application) => {
22- return (
23- <tr key={application.id}>
24- <td>{application.role.title}</td>
25- <td>{application.new_status.label}</td>
26- </tr>
27- );
28- })}
29- </React.Fragment>
30- );
8+ return <CandidateListItem candidate={candidate} />;
319 });
3210 }
3311
src/components/candidateListItem.js+42−0
@@ -0,0 +1,42 @@
1+import React, { useState } from "react";
2+import moment from "moment";
3+
4+function CandidateListItem(props) {
5+ const candidate = props.candidate;
6+ const [visibility, setVisibility] = useState(false);
7+
8+ let toggleApplicationDetail = (ev) => {
9+ console.log("clicked");
10+ setVisibility(!visibility);
11+ };
12+
13+ return (
14+ <React.Fragment key={candidate.id}>
15+ <tr onClick={toggleApplicationDetail}>
16+ <td>{candidate.name}</td>
17+ <td>
18+ {candidate.applications[0].new_status.color}
19+ {candidate.applications[0].new_status.label}
20+ </td>
21+ <td>{candidate.applications.lengtd}</td>
22+ <td>{moment(candidate.profile.updated).fromNow()}</td>
23+ <td>{candidate.scorecard_count}</td>
24+ <td>{candidate.profile.nimble_score}</td>
25+ <td>{candidate.note_count}</td>
26+ </tr>
27+ {candidate.applications.map((application) => {
28+ return (
29+ <tr
30+ key={application.id}
31+ className={visibility ? "d-table-row" : "d-none"}
32+ >
33+ <td>{application.role.title}</td>
34+ <td>{application.new_status.label}</td>
35+ </tr>
36+ );
37+ })}
38+ </React.Fragment>
39+ );
40+}
41+
42+export default CandidateListItem;
src/components/candidatesList.js+1−1
@@ -6,7 +6,7 @@ function CandidatesList(props) {
66 const candidates = props.candidates.results;
77
88 return (
9- <table>
9+ <table className="table">
1010 <thead>
1111 <tr>
1212 <th>Candidate name</th>
src/index.js+7−6
@@ -1,14 +1,15 @@
1-import React from 'react';
2-import ReactDOM from 'react-dom';
3-import './index.css';
4-import App from './App';
5-import * as serviceWorker from './serviceWorker';
1+import React from "react";
2+import ReactDOM from "react-dom";
3+import "bootstrap/dist/css/bootstrap.css";
4+import "./index.css";
5+import App from "./App";
6+import * as serviceWorker from "./serviceWorker";
67
78 ReactDOM.render(
89 <React.StrictMode>
910 <App />
1011 </React.StrictMode>,
11- document.getElementById('root')
12+ document.getElementById("root")
1213 );
1314
1415 // If you want your app to work offline and load faster, you can change