Skip to content

Commit

Permalink
refactor: resolve code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinusnathaniel committed Dec 26, 2020
1 parent 26cb825 commit 7297019
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/components/form/SearchContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const INITIAL_VALUES: SearchFormValueType = {
const SearchContainer = () => {
const {
values: {
queryParams: { title, description, https, cors, category },
queryParams: { title, description, https, category },
searchDescription,
selectCategory,
isRandom,
Expand Down Expand Up @@ -177,9 +177,9 @@ const SearchContainer = () => {
value={category}
onChange={handleChange}
>
{categories?.map((category: string, index) => (
{categories?.map((categoryItem: string, index) => (
<Text as="option" key={index}>
{category}
{categoryItem}
</Text>
))}
</Select>
Expand Down
28 changes: 14 additions & 14 deletions src/pages/all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ const All = () => {
const filterData = () => {
const kword = keyword.toLowerCase();
const updateFilteredData = sortedData.filter(
(data) =>
data.API.toLowerCase().indexOf(kword) > -1 ||
data.Description.toLowerCase().indexOf(kword) > -1
(entry) =>
entry.API.toLowerCase().indexOf(kword) > -1 ||
entry.Description.toLowerCase().indexOf(kword) > -1
);

setFiltedData(updateFilteredData);
};

useEffect(() => {
if (data?.entries) {
const updateSortedData =
data &&
data.entries.sort((a, b) => {
if (a.API < b.API) {
return -1;
}
if (a.API > b.API) {
return 1;
}
return 0;
});
const updateSortedData = data && data.entries;

updateSortedData.sort((a, b) => {
if (a.API < b.API) {
return -1;
}
if (a.API > b.API) {
return 1;
}
return 0;
});
setSortedData(updateSortedData);
}
}, [data]);
Expand Down

0 comments on commit 7297019

Please sign in to comment.