Skip to content

Commit 35bead5

Browse files
author
crzypatchwork
committed
latest search
1 parent 1880c07 commit 35bead5

17 files changed

+89
-70
lines changed

src/components/input/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const Input = ({
1414
onWheel = () => null,
1515
disabled,
1616
value,
17-
pattern
17+
pattern,
18+
onKeyPress
1819
}) => (
1920
<div className={styles.container}>
2021
<label>
@@ -28,9 +29,9 @@ export const Input = ({
2829
defaultValue={value}
2930
onChange={onChange}
3031
onBlur={onBlur}
31-
disabled={disabled}
3232
pattern={pattern}
3333
onWheel={onWheel}
34+
onKeyPress={onKeyPress}
3435
/>
3536
<p>{label}</p>
3637
</label>

src/pages/search/index.js

Lines changed: 84 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ export class Search extends Component {
540540
{ id: 7, value: 'recent sales' },
541541
{ id: 8, value: '1D' },
542542
{ id: 9, value: '1W' },
543-
{ id: 10, value: '1M' }
543+
{ id: 10, value: '1M' },
544+
{ id: 11, value: 'ATH' }
544545
],
545546
select: [],
546547
mouse: false,
@@ -561,7 +562,7 @@ export class Search extends Component {
561562
handleChange = (e) => {
562563
this.setState({ [e.target.name]: e.target.value })
563564

564-
if (this.state.search.length >= 1) this.search()
565+
//if (this.state.search.length >= 1) this.search()
565566
}
566567

567568
update = async (e, reset) => {
@@ -609,6 +610,17 @@ export class Search extends Component {
609610
})
610611
}
611612

613+
if (e === 'ATH') {
614+
let list = await fetchDay(new Date('2021-05-01').toISOString(), this.state.offset)
615+
list = list.map(e => e.token)
616+
list = [...this.state.feed, ...(list)]
617+
list = _.uniqBy(list, 'id')
618+
console.log('ath', list)
619+
this.setState({
620+
feed: list
621+
})
622+
}
623+
612624
if (e === 'num') {
613625
let res = await fetchFeed(Number(this.state.search) + 1 - this.state.offset)
614626
res = res.filter(e => !arr.includes(e.creator_id))
@@ -693,92 +705,97 @@ export class Search extends Component {
693705
let restricted = await getRestrictedAddresses()
694706
result = _.uniqBy([...this.state.feed, ...result], 'creator_id')
695707
result = result.filter(e => !restricted.includes(e.creator_id))
696-
this.setState({ feed: [...result], flag : true })
708+
this.setState({ feed: [...result], flag: true })
697709
}
698710

699711

700712
search = async (e) => {
701713

714+
console.log(e)
715+
702716
this.setState({ items: [], feed: [], search: e })
703717
this.setState({ subjkt: await fetchSubjkts(this.state.search) })
704718

705-
if ((this.state.subjkt[0]?.hdao_balance > 30000000) || (isFloat(Number(this.state.search)))) {
706-
console.log(isFloat(Number(this.state.search)))
707-
this.setState({ feed: await fetchCreations(this.state.subjkt[0].address, this.state.offset), select: 'creations' })
708-
} else if (!isNaN(this.state.search)) {
719+
if (!isNaN(this.state.search)) {
709720
this.setState({ feed: await fetchFeed(Number(this.state.search) + 1), select: 'num' })
710721
} else {
711722
this.setState({ feed: _.uniqBy(await fetchTag(this.state.search.toLowerCase(), 9999999), 'creator_id'), select: 'tag' })
712723
}
713724

725+
726+
console.log(this.state.feed)
714727
}
715728

716-
hoverState = (bool) => this.setState({ mouse: bool })
729+
hoverState = (bool) => this.setState({ mouse: bool })
717730

718-
select = (id) => this.setState({ select: [...this.state.select, id] })
731+
select = (id) => this.setState({ select: [...this.state.select, id] })
719732

720-
loadMore = () => {
721-
this.setState({ offset: this.state.offset + 15 })
722-
this.update(this.state.select, false)
723-
}
733+
loadMore = () => {
734+
this.setState({ offset: this.state.offset + 15 })
735+
this.update(this.state.select, false)
736+
}
724737

725-
render() {
738+
handleKey = (e) => {
739+
console.log(this.state.search)
740+
if (e.key == 'Enter') this.search(this.state.search)
741+
}
726742

727-
return (
728-
<Page>
729-
<Container>
730-
<Padding>
731-
<Input
732-
type="text"
733-
name="search"
734-
onMouseEnter={() => this.hoverState(true)}
735-
onMouseLeave={() => this.hoverState(false)}
736-
onChange={e => this.search(e.target.value)}
737-
label="objkt id, artists, tags"
738-
placeholder="objkt id, artists, tags"
739-
/>
740-
{
741-
<div style={{ marginTop: '15px' }}>
742-
{this.state.tags.map(e => <a className='tag' href='#' onClick={() => {
743-
this.update(e.value, true)
744-
}}>{e.value} </a>)}
745-
</div>
746-
}
747-
{
748-
(this.state.subjkt.length > 0) && (this.state.search !== "") ?
749-
<div style={{ maxHeight: '200px', overflow: 'scroll' }}>
750-
{
751-
this.state.subjkt.map(e => <div style={{ marginTop: '10px' }}><a href={`/${e.name}`}>{e.name}</a> {e.metadata.description}</div>)
752-
}
743+
render() {
744+
745+
return (
746+
<Page>
747+
<Container>
748+
<Padding>
749+
<Input
750+
type="text"
751+
name="search"
752+
onChange={this.handleChange}
753+
label="search objkt id, artists, tags (press Enter)"
754+
placeholder="search objkt id, artists, tags (press Enter)"
755+
onKeyPress={this.handleKey}
756+
/>
757+
{
758+
<div style={{ marginTop: '15px' }}>
759+
{this.state.tags.map(e => <a className='tag' href='#' onClick={() => {
760+
this.update(e.value, true)
761+
}}>{e.value} </a>)}
753762
</div>
763+
}
764+
{
765+
(this.state.subjkt.length > 0) && (this.state.search !== "") ?
766+
<div style={{ maxHeight: '200px', overflow: 'scroll' }}>
767+
{
768+
this.state.subjkt.map(e => <div style={{ marginTop: '10px' }}><a href={`/${e.name}`}>{e.name}</a> {e.metadata.description}</div>)
769+
}
770+
</div>
771+
:
772+
undefined
773+
}
774+
</Padding>
775+
</Container>
776+
<Container xlarge>
777+
{
778+
this.state.feed.length > 0 ?
779+
<InfiniteScroll
780+
dataLength={this.state.feed.length}
781+
next={this.loadMore}
782+
hasMore={this.state.hasMore}
783+
loader={undefined}
784+
endMessage={undefined}
785+
>
786+
<Container>
787+
<Padding>
788+
{this.state.feed.map((item, index) => (
789+
<FeedItem key={`${item.id}-${index}`} {...item} />
790+
))}
791+
</Padding>
792+
</Container>
793+
</InfiniteScroll>
754794
:
755795
undefined
756796
}
757-
</Padding>
758-
</Container>
759-
<Container xlarge>
760-
{
761-
this.state.feed.length > 0 ?
762-
<InfiniteScroll
763-
dataLength={this.state.feed.length}
764-
next={this.loadMore}
765-
hasMore={this.state.hasMore}
766-
loader={undefined}
767-
endMessage={undefined}
768-
>
769-
<Container>
770-
<Padding>
771-
{this.state.feed.map((item, index) => (
772-
<FeedItem key={`${item.id}-${index}`} {...item} />
773-
))}
774-
</Padding>
775-
</Container>
776-
</InfiniteScroll>
777-
:
778-
undefined
779-
}
780-
</Container>
781-
</Page>
782-
)
797+
</Container>
798+
</Page>
799+
)
800+
}
783801
}
784-
}

src/pages/search/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
margin-bottom: 6px;
88
font-size: 16px;
99
font-weight: bold;
10-
}
10+
}
11+

src/styles/IBMPlexMono-Bold.ttf

109 KB
Binary file not shown.

src/styles/IBMPlexMono-BoldItalic.ttf

115 KB
Binary file not shown.

src/styles/IBMPlexMono-ExtraLight.ttf

107 KB
Binary file not shown.
115 KB
Binary file not shown.

src/styles/IBMPlexMono-Italic.ttf

115 KB
Binary file not shown.

src/styles/IBMPlexMono-Light.ttf

106 KB
Binary file not shown.
114 KB
Binary file not shown.

0 commit comments

Comments
 (0)