Skip to content

Commit

Permalink
FIlter props names
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed May 28, 2020
1 parent 91cb399 commit 3bed47b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/admin/apps/MarketplaceTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function MarketplaceTable({ setModal }) {
const debouncedText = useDebouncedValue(params.text, 500);
const debouncedSort = useDebouncedValue(sort, 200);

const [data, total] = useMarketplaceApps({ debouncedSort, debouncedText, ...params });
const [data, total] = useMarketplaceApps({ sort: debouncedSort, text: debouncedText, ...params });

const getLoggedInCloud = useMethod('cloud:checkUserLoggedIn');
const isLoggedIn = getLoggedInCloud();
Expand Down
8 changes: 4 additions & 4 deletions client/admin/apps/hooks/useMarketplaceApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const registerListeners = (listeners) => {
/* TODO
* If order is reversed and search is performed, the result will return in the wrong order, then refresh correctly
*/
export function useMarketplaceApps({ debouncedText, debouncedSort, current, itemsPerPage }) {
export function useMarketplaceApps({ text, sort, current, itemsPerPage }) {
const [data, setData] = useState({});
const ref = useRef();
ref.current = data;
Expand Down Expand Up @@ -109,9 +109,9 @@ export function useMarketplaceApps({ debouncedText, debouncedSort, current, item

const filteredValues = useMemo(() => {
if (data.length) {
let filtered = debouncedSort[1] === 'asc' ? data : data.reverse();
let filtered = sort[1] === 'asc' ? data : data.reverse();

filtered = debouncedText ? filtered.filter((app) => app.name.toLowerCase().indexOf(debouncedText.toLowerCase()) > -1) : filtered;
filtered = text ? filtered.filter((app) => app.name.toLowerCase().indexOf(text.toLowerCase()) > -1) : filtered;

const filteredLength = filtered.length;

Expand All @@ -122,7 +122,7 @@ export function useMarketplaceApps({ debouncedText, debouncedSort, current, item
return [filtered, filteredLength];
}
return [null, 0];
}, [debouncedText, debouncedSort[1], stringifiedData, current, itemsPerPage]);
}, [text, sort[1], stringifiedData, current, itemsPerPage]);

return [...filteredValues];
}

0 comments on commit 3bed47b

Please sign in to comment.