-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add global nft search * Rename feature * Fix legal footer links
- Loading branch information
1 parent
08d2cf8
commit 5ee1f64
Showing
17 changed files
with
115 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { PriceInput } from './price-input'; | ||
import { SearchInput } from './search-input'; | ||
|
||
export { PriceInput, SearchInput }; | ||
export { PriceInput }; |
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
frontend/src/components/inputs/search-input/search-input.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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { NFTSearch } from './nft-search'; | ||
|
||
export { NFTSearch }; |
3 changes: 3 additions & 0 deletions
3
frontend/src/features/nft-search/components/nft-search/index.ts
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,3 @@ | ||
import { NFTSearch } from './nft-search'; | ||
|
||
export { NFTSearch }; |
33 changes: 33 additions & 0 deletions
33
frontend/src/features/nft-search/components/nft-search/nft-search.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,33 @@ | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { FormProvider, useForm } from 'react-hook-form'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { Input } from '@/components'; | ||
import { ROUTE } from '@/consts'; | ||
|
||
import SearchSVG from '../../assets/search.svg?react'; | ||
import { FIELD_NAME, SCHEMA } from '../../consts'; | ||
import { useNFTSearchParam } from '../../hooks'; | ||
|
||
function NFTSearch() { | ||
const param = useNFTSearchParam(); | ||
|
||
const form = useForm({ values: { [FIELD_NAME.QUERY]: param.value }, resolver: zodResolver(SCHEMA) }); | ||
const navigate = useNavigate(); | ||
|
||
const handleSubmit = form.handleSubmit(({ query }) => { | ||
const search = query ? param.set(query) : param.reset(); | ||
|
||
navigate({ pathname: ROUTE.NFTS, search }); | ||
}); | ||
|
||
return ( | ||
<FormProvider {...form}> | ||
<form onSubmit={handleSubmit}> | ||
<Input name={FIELD_NAME.QUERY} icon={SearchSVG} label="NFT name/Account address" size="small" /> | ||
</form> | ||
</FormProvider> | ||
); | ||
} | ||
|
||
export { NFTSearch }; |
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,11 @@ | ||
import { z } from 'zod'; | ||
|
||
const FIELD_NAME = { | ||
QUERY: 'query', | ||
}; | ||
|
||
const SCHEMA = z.object({ | ||
[FIELD_NAME.QUERY]: z.string().trim(), | ||
}); | ||
|
||
export { FIELD_NAME, SCHEMA }; |
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,24 @@ | ||
import { useSearchParams } from 'react-router-dom'; | ||
|
||
import { FIELD_NAME } from './consts'; | ||
|
||
function useNFTSearchParam() { | ||
const [params] = useSearchParams(); | ||
const value = params.get(FIELD_NAME.QUERY) || ''; | ||
|
||
const set = (query: string) => { | ||
params.set(FIELD_NAME.QUERY, query); | ||
|
||
return params.toString(); | ||
}; | ||
|
||
const reset = () => { | ||
params.delete(FIELD_NAME.QUERY); | ||
|
||
return ''; | ||
}; | ||
|
||
return { value, set, reset }; | ||
} | ||
|
||
export { useNFTSearchParam }; |
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,4 @@ | ||
import { NFTSearch } from './components'; | ||
import { useNFTSearchParam } from './hooks'; | ||
|
||
export { NFTSearch, useNFTSearchParam }; |
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