-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): preliminary nft search stuff
- Loading branch information
plondon
committed
Apr 25, 2022
1 parent
a1cefdd
commit ff8680e
Showing
12 changed files
with
101 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/blockchain-wallet-v4-frontend/src/layouts/Explore/Header/NftSearch/NftSearch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { connect, ConnectedProps } from 'react-redux' | ||
import { bindActionCreators } from 'redux' | ||
import { Field } from 'redux-form' | ||
|
||
import { SpinningLoader } from 'blockchain-info-components' | ||
import { SelectBox } from 'components/Form' | ||
import { actions, selectors } from 'data' | ||
import { RootState } from 'data/rootReducer' | ||
import { debounce } from 'utils/helpers' | ||
|
||
const NftSearch: React.FC<Props> = ({ formValues, nftActions, nftSearch }) => { | ||
const [input, setInput] = useState('') | ||
|
||
const handleInputChange = (e: any) => { | ||
setInput(e) | ||
} | ||
|
||
useEffect(() => { | ||
if (input) { | ||
nftActions.nftSearch({ search: input }) | ||
} | ||
}, [input]) | ||
|
||
return ( | ||
<Field | ||
component={SelectBox} | ||
elements={[ | ||
{ | ||
group: '', | ||
items: [] | ||
} | ||
]} | ||
hideIndicator | ||
name='search' | ||
onInputChange={debounce((e) => handleInputChange(e), 500)} | ||
label='Collections or items' | ||
cursor='initial' | ||
noOptionsMessage={() => { | ||
return nftSearch.cata({ | ||
Failure: () => null, | ||
Loading: () => <SpinningLoader width='14px' height='14px' borderWidth='3px' />, | ||
NotAsked: () => null, | ||
Success: () => null | ||
}) | ||
}} | ||
placeholder='Collections or items' | ||
/> | ||
) | ||
} | ||
|
||
const mapStateToProps = (state: RootState) => ({ | ||
formValues: selectors.form.getFormValues('nftSearch')(state), | ||
nftSearch: selectors.components.nfts.getNftSearch(state) | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
nftActions: bindActionCreators(actions.components.nfts, dispatch) | ||
}) | ||
|
||
const connector = connect(mapStateToProps, mapDispatchToProps) | ||
|
||
type Props = ConnectedProps<typeof connector> | ||
|
||
export default connector(NftSearch) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
packages/blockchain-wallet-v4-frontend/src/layouts/Explore/NftSearch/NftSearch.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters