Skip to content

Commit

Permalink
chore: shuffle tools search
Browse files Browse the repository at this point in the history
  • Loading branch information
iib0011 committed Jun 26, 2024
1 parent adc114a commit 781cd16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
29 changes: 14 additions & 15 deletions .idea/workspace.xml

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

8 changes: 6 additions & 2 deletions src/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useState } from 'react';
import { DefinedTool } from '@tools/defineTool';
import { filterTools, tools } from '@tools/index';
import { useNavigate } from 'react-router-dom';
import _ from 'lodash';

const exampleTools: { label: string; url: string }[] = [
{
Expand All @@ -23,14 +24,16 @@ const exampleTools: { label: string; url: string }[] = [
];
export default function Hero() {
const [inputValue, setInputValue] = useState<string>('');
const [filteredTools, setFilteredTools] = useState<DefinedTool[]>(tools);
const [filteredTools, setFilteredTools] = useState<DefinedTool[]>(
_.shuffle(tools)
);
const navigate = useNavigate();
const handleInputChange = (
event: React.ChangeEvent<{}>,
newInputValue: string
) => {
setInputValue(newInputValue);
setFilteredTools(filterTools(tools, newInputValue));
setFilteredTools(_.shuffle(filterTools(tools, newInputValue)));
};
return (
<Box width={{ xs: '90%', md: '80%', lg: '60%' }}>
Expand Down Expand Up @@ -61,6 +64,7 @@ export default function Hero() {
sx={{ mb: 2 }}
autoHighlight
options={filteredTools}
inputValue={inputValue}
getOptionLabel={(option) => option.name}
renderInput={(params) => (
<TextField
Expand Down

0 comments on commit 781cd16

Please sign in to comment.