Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explorer] Adds Search Filter #1959

Merged
merged 7 commits into from
May 13, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change placeholder text for address and tx search
lint changes
  • Loading branch information
Stella Cannefax committed May 13, 2022
commit 3b30252d75270207f6195648772f9294b207a542
19 changes: 16 additions & 3 deletions explorer/client/src/components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@ import { navigateWithUnknown } from '../../utils/searchUtil';

import styles from './Search.module.css';

type SearchCategory = 'all' | 'transactions' | 'addresses' | 'objects';
function getPlaceholderText(category: SearchCategory) {
switch (category) {
case 'addresses':
return `Search by address`;
case 'transactions':
return `Search by digest`;
case 'objects':
case 'all':
return 'Search by ID';
}
}

function Search() {
const [input, setInput] = useState('');
const [category, setCategory] = useState('all');
const [category, setCategory] = useState('all' as SearchCategory);
const navigate = useNavigate();

const [pleaseWaitMode, setPleaseWaitMode] = useState(false);
Expand Down Expand Up @@ -45,7 +58,7 @@ function Search() {
);
const handleCategoryChange = useCallback(
(e: React.ChangeEvent<HTMLSelectElement>) =>
setCategory(e.currentTarget.value),
setCategory(e.currentTarget.value as SearchCategory),
[setCategory]
);

Expand All @@ -58,7 +71,7 @@ function Search() {
<input
className={styles.searchtext}
id="searchText"
placeholder="Search by ID"
placeholder={getPlaceholderText(category)}
value={input}
onChange={handleTextChange}
type="text"
Expand Down