Skip to content

Commit

Permalink
fixed console warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cnix273 committed Apr 6, 2021
1 parent c223f7e commit f73c9d2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion node_modules/.cache/.eslintcache

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/components/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Search extends Component {
employees.map(employee => {
employee.dob.date = employee.dob.date.split("T")[0];
employee.dob.date = employee.dob.date.split("-").reverse().join("-");
return employee.dob.date;
})
this.setState({
employees: employees,
Expand All @@ -40,6 +41,7 @@ class Search extends Component {
employees.filter(employee => {
if (employee.name.first.toLowerCase().search(searchParam) !== -1 || employee.name.last.toLowerCase().search(searchParam) !== -1)
{filteredList.push(employee)}
return filteredList;
});

// Set employees array in state equal to new filtered list of employees
Expand All @@ -58,7 +60,7 @@ class Search extends Component {
let sorted = this.state.sorted;

// Sorting employees alphabetically
if (this.state.sorted == false) {
if (this.state.sorted === false) {
sortedEmployees.sort((a,b) => {
let fa = a.name.first.toLowerCase();
let fb = b.name.first.toLowerCase();
Expand All @@ -80,7 +82,7 @@ class Search extends Component {
}

// If employees have the same first name, sort by last name
if (fa = fb) {
if (fa === fb) {
if (la < lb) {
return -1;
}
Expand All @@ -96,7 +98,7 @@ class Search extends Component {
}

// Sorting employees reverse alphabetically
if (sorted == true) {
if (sorted === true) {
// Sort employees by first name in reverse alphabetical order
sortedEmployees.sort((a,b) => {
let fa = a.name.first.toLowerCase();
Expand All @@ -119,7 +121,7 @@ class Search extends Component {
}

// If employees have the same first name, sort by last name
if (fa = fb) {
if (fa === fb) {
if (la < lb) {
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchResults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function SearchResults(props) {
<tbody>
{props.employees.map((employee) => {
return(<tr>
<td><img src={employee.picture.medium}></img></td>
<td><img alt={employee.name.first} src={employee.picture.medium}></img></td>
<td className="name">{employee.name.first} {employee.name.last}</td>
<td>{employee.email}</td>
<td>{employee.phone}</td>
Expand Down
4 changes: 3 additions & 1 deletion src/utils/API.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import axios from "axios";

export default {
const employeeAPI = {
getEmployeeList: function() {
return axios.get("https://randomuser.me/api/?results=50&nat=us");
}
};

export default employeeAPI;
Binary file modified walkthrough.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f73c9d2

Please sign in to comment.