INNER CODE UNIT · JavaScript
uniqueCategories
collabnix/kubetools · portal/KubeToolsPortal.js:161
const uniqueCategories = ['All', ...new Set(toolsData.map(tool => tool.category))];
setCategories(uniqueCategories);
// Initialize votes
const initialVotes = {};
toolsData.forEach(tool => {
initialVotes[tool.name] = 0;
});
setVotes(initialVotes);
}, []);
// Filter tools based on selected category and search query
const filteredTools = tools.filter(tool => {
const matchesCategory = selectedCategory === 'All' || tool.category === selectedCategory;
const matchesSearch = tool.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
tool.description.toLowerCase().includes(searchQuery.toLowerCase());
return matchesCategory && matchesSearch;
});