Skip to content

Commit 4341ff7

Browse files
committed
Made changes in SearchBar Component
1 parent d9368b3 commit 4341ff7

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

frontend/family_tree/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
margin-right: 10px;
4747
width: 150px;
4848
height: 170px;
49-
}
49+
}

frontend/family_tree/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import StudentData from "./Data.json";
77
function App() {
88
return (
99
<div className="App">
10-
<SearchBar placeholder="Enter the Name or Roll Number..." Student_Data={StudentData} />
10+
<SearchBar placeholder="Enter the Name or Roll Number..." studentData={StudentData} />
1111
<div className="help">
1212
<Help />
1313
</div>

frontend/family_tree/src/Components/SearchBar.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import "../Styles/SearchBar.css";
33
import SearchIcon from "@material-ui/icons/Search";
44
import CloseIcon from "@material-ui/icons/Close"
55

6-
function SearchBar({ placeholder, Student_Data }) {
6+
function SearchBar({ placeholder, studentData }) {
77
const [filteredData, setFilteredData] = useState([]);
88
const [wordEntered, setWordEntered] = useState("");
99

1010
const handleFilter = (event) => {
1111
const searchWord = event.target.value;
12-
setWordEntered(searchWord);
12+
setWordEntered(searchWord);
1313
if (searchWord.length < 3) {
1414
setFilteredData([]);
1515
} else {
16-
const FilteredResults = Student_Data.filter((value) => {
17-
return value.student.name.toLowerCase().includes(searchWord.toLowerCase()) + value.student.id.toLowerCase().includes(searchWord.toLowerCase());
18-
});
19-
setFilteredData(FilteredResults);
16+
const filteredResults = studentData.filter((query) => {
17+
return query.student.name.toLowerCase().includes(searchWord.toLowerCase()) + query.student.id.toLowerCase().includes(searchWord.toLowerCase());
18+
});
19+
setFilteredData(filteredResults);
2020
}
2121
};
2222

@@ -46,9 +46,7 @@ function SearchBar({ placeholder, Student_Data }) {
4646
<div className="dataResult">
4747
{filteredData.slice(0, 5).map((value) => {
4848
return (
49-
// <a className="dataItem" href={value.link} rel="noreferrer" target="_blank">
50-
<p className="dataItem">{value.student.name + " (" + value.student.id + ")"} </p>
51-
// </a>
49+
<p className="dataItem">{`${value.student.name} (${value.student.id})`} </p>
5250
);
5351
})}
5452
</div>

frontend/family_tree/src/Data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@
194194
},
195195
"parentId": "B19XXYYY"
196196
}
197-
]
197+
]

0 commit comments

Comments
 (0)