|
|
@ -2,12 +2,13 @@ import { useState } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import { Fade } from '../../components/animation/Fade'; |
|
|
|
import { Fade } from '../../components/animation/Fade'; |
|
|
|
import { SearchBar } from '../../components/search/SearchBar'; |
|
|
|
import { SearchBar } from '../../components/search/SearchBar'; |
|
|
|
|
|
|
|
import { SearchFilterBar } from '../../components/search/SearchFilterBar'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
SearchEmptyError, |
|
|
|
SearchEmptyError, |
|
|
|
|
|
|
|
SearchFetching, |
|
|
|
SearchInvalidError, |
|
|
|
SearchInvalidError, |
|
|
|
SearchUnknownError, |
|
|
|
SearchUnknownError, |
|
|
|
} from '../../components/search/SearchError'; |
|
|
|
} from '../../components/search/SearchStates'; |
|
|
|
import { SearchFilterBar } from '../../components/search/SearchFilterBar'; |
|
|
|
|
|
|
|
import useDebounce from '../../utils/debounce'; |
|
|
|
import useDebounce from '../../utils/debounce'; |
|
|
|
import { useQueryParam, useSyncQueryParam } from '../../utils/queryParams'; |
|
|
|
import { useQueryParam, useSyncQueryParam } from '../../utils/queryParams'; |
|
|
|
import { sanitizeString } from '../../utils/string'; |
|
|
|
import { sanitizeString } from '../../utils/string'; |
|
|
@ -54,6 +55,9 @@ export function MessageSearch() { |
|
|
|
isMessagesFound || isFetching, |
|
|
|
isMessagesFound || isFetching, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Coalesce GraphQL + PI results
|
|
|
|
|
|
|
|
const isAnyFetching = isFetching || isPiFetching; |
|
|
|
|
|
|
|
const isAnyError = isError || isPiError; |
|
|
|
const isAnyMessageFound = isMessagesFound || piMessageList.length > 0; |
|
|
|
const isAnyMessageFound = isMessagesFound || piMessageList.length > 0; |
|
|
|
const messageListResult = isMessagesFound ? messageList : piMessageList; |
|
|
|
const messageListResult = isMessagesFound ? messageList : piMessageList; |
|
|
|
console.log(isPiError, isPiFetching, piMessageList); |
|
|
|
console.log(isPiError, isPiFetching, piMessageList); |
|
|
@ -66,7 +70,7 @@ export function MessageSearch() { |
|
|
|
<SearchBar |
|
|
|
<SearchBar |
|
|
|
value={searchInput} |
|
|
|
value={searchInput} |
|
|
|
onChangeValue={setSearchInput} |
|
|
|
onChangeValue={setSearchInput} |
|
|
|
isFetching={isFetching} |
|
|
|
isFetching={isAnyFetching} |
|
|
|
placeholder="Search by address, hash, or message id" |
|
|
|
placeholder="Search by address, hash, or message id" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div className="w-full min-h-[38rem] mt-5 bg-white shadow-md border rounded overflow-auto relative"> |
|
|
|
<div className="w-full min-h-[38rem] mt-5 bg-white shadow-md border rounded overflow-auto relative"> |
|
|
@ -85,15 +89,19 @@ export function MessageSearch() { |
|
|
|
onChangeEndTimestamp={setEndTimeFilter} |
|
|
|
onChangeEndTimestamp={setEndTimeFilter} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<Fade show={!isError && isValidInput && isAnyMessageFound}> |
|
|
|
<Fade show={!isAnyError && isValidInput && isAnyMessageFound}> |
|
|
|
<MessageTable messageList={messageListResult} isFetching={isFetching} /> |
|
|
|
<MessageTable messageList={messageListResult} isFetching={isAnyFetching} /> |
|
|
|
</Fade> |
|
|
|
</Fade> |
|
|
|
|
|
|
|
<SearchFetching |
|
|
|
|
|
|
|
show={!isAnyError && isValidInput && !isAnyMessageFound && isAnyFetching} |
|
|
|
|
|
|
|
isPiFetching={isPiFetching} |
|
|
|
|
|
|
|
/> |
|
|
|
<SearchEmptyError |
|
|
|
<SearchEmptyError |
|
|
|
show={!isError && isValidInput && !isFetching && !isAnyMessageFound} |
|
|
|
show={!isAnyError && isValidInput && !isAnyMessageFound && !isAnyFetching} |
|
|
|
hasInput={hasInput} |
|
|
|
hasInput={hasInput} |
|
|
|
allowAddress={true} |
|
|
|
allowAddress={true} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<SearchUnknownError show={isError && isValidInput} /> |
|
|
|
<SearchUnknownError show={isAnyError && isValidInput} /> |
|
|
|
<SearchInvalidError show={!isValidInput} allowAddress={true} /> |
|
|
|
<SearchInvalidError show={!isValidInput} allowAddress={true} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</> |
|
|
|
</> |
|
|
|