Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
refactor: remove lodash dep (#1156)
Browse files Browse the repository at this point in the history
closes #1157
  • Loading branch information
mtfoley committed Sep 24, 2021
1 parent 6043be8 commit d2fca47
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion npm-shrinkwrap.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"dayjs": "^1.10.6",
"graphql": "^15.5.1",
"humanize-duration": "^3.27.0",
"lodash": "^4.17.21",
"onegraph-apollo-client": "^3.1.2",
"onegraph-auth": "^4.0.2",
"react": "^17.0.2",
Expand Down
19 changes: 16 additions & 3 deletions src/components/ListGoals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@ import {Select} from "../styles/Select";
import RepoListItem from "../components/RepoListItem";
import Card from "../components/Card";
import List from "../styles/List";
import {merge} from "lodash";
import sortBy from "lodash/sortBy";
//import {merge} from "lodash";
//import sortBy from "lodash/sortBy";
import Search from "../styles/Search";
import {EmptyPlaceholder} from "../styles/EmptyPlaceholder";
import {SearchIcon} from "@primer/octicons-react";
import {fontSize} from "../styles/variables";
function sortBy(data, field) {
data.sort(function(a, b) {
if (!a[field] || !b[field]) return 0;
return a[field] < b[field] ? -1 : (b[field] < b[field] ? 1 : 0);
});
return data;
}
function merge(goals, additionalData) {
return goals.map(item => {
const toAdd = additionalData.find(d => d["full_name"] === item["full_name"]) || {};
return {...item, ...toAdd};
});
}

function ListGoals({goals, data}) {
const goalsWithData = merge(goals.nodes, data);
const goalsWithData = merge(goals.nodes, data || []);
const [listGoals, setGoals] = useState(goalsWithData);
const [searchTerm, setSearchTerm] = useState("");

Expand Down
2 changes: 1 addition & 1 deletion src/tests/ListGoals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {goals} = data;
test("container component should have no violations", async() => {
const {container} = render(
<BrowserRouter>
<ListGoals goals={goals} />
<ListGoals goals={goals} data={[]} />
</BrowserRouter>,
);
const results = await axe(container);
Expand Down

0 comments on commit d2fca47

Please sign in to comment.