I have the following code in index.js which dipslay all employee information from json file. --- codesandboxCode ---
return (
<div className="App">
<input
value={this.state.input}
type="text"
onChange={e => this.onSearchTextChange(e.target.value)}
/>
<List divided>
{cardData.data.Table.map(results => (
<div class="body">
<h3 className="title">{results.first_name}</h3>
<div className="row">
<div className="col-md-3 col-sm-6">
{" "}
Department: {results.Department}
</div>
</div>
{/* row for Location cubicle Prof */}
<Link
to={{ pathname: `/cards/${results.id}`, state: results }}
className={`card-wrapper restore-${results.id}`}
>
display
</Link>
</div>
))}
</List>
</div>
);
I also have details.js file which display selected employee detail information as follows
render() {
const id = this.props.match.params.id;
const data = cardData.data.Table.find(item => item.id === id);
return (
// Card details compoment
<div className="card-details">
<h2>{data.first_name}</h2>
<h2>{data.id}</h2>
<Link
to={{
pathname: "/",
state: this.props.location.state
}}
>
<button>Return to list</button>
</Link>
</div>
);
How can i display employees in the same department name in the selected record detail Page?.
I have data i have a data as shown below on employee 1001 detail page i would like to show Id
and first_name
of employee with id 1003 because both in the same department
"data": {
"Table": [
{
"id": "1001",
"first_name": "Alez",
"Department": "IT"
},
{
"id": "1002",
"first_name": "Baro",
"Department": "Accounting"
},
{
"id": "1003",
"first_name": "Tata",
"Department": "IT"
},