Skip to content

Commit 00efcd5

Browse files
committed
primary vs secondary
1 parent f5ea977 commit 00efcd5

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

src/pages/display/index.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ query creatorGallery($address: String!) {
9292
status
9393
amount_left
9494
creator_id
95+
contract_version
9596
creator {
9697
address
9798
}
@@ -413,7 +414,7 @@ export default class Display extends Component {
413414
return objkts
414415
}
415416

416-
creationsForSale = async () => {
417+
creationsForSale = async (forSaleType) => {
417418
this.setState({ collectionType: 'forSale' })
418419

419420
let v1Swaps = this.state.marketV1.filter(item => {
@@ -423,15 +424,37 @@ export default class Display extends Component {
423424

424425
this.setState({ marketV1: v1Swaps, loading: false })
425426

426-
this.setState({
427-
objkts: await this.filterCreationsForSale(this.state.objkts),
428-
items: []
429-
})
427+
if (forSaleType !== null) {
428+
if (forSaleType == 0) {
429+
this.setState({
430+
objkts: await this.filterCreationsForSalePrimary(this.state.objkts),
431+
items: []
432+
})
433+
} else if (forSaleType == 1) {
434+
this.setState({
435+
objkts: await this.filterCreationsForSaleSecondary(this.state.objkts),
436+
items: []
437+
})
438+
}
439+
} else {
440+
console.log("forSaleType is null")
441+
}
430442

431443
this.setState({ items: this.state.objkts.slice(0, 15), offset: 15 })
432444
}
433445

434-
filterCreationsForSale = async () => {
446+
filterCreationsForSalePrimary = async () => {
447+
let objkts = this.state.creations.filter(item => {
448+
const swaps = item.swaps.filter(swaps => {
449+
return swaps.status == 0 && swaps.contract_version == 2 && swaps.creator_id == this.state.wallet
450+
})
451+
return swaps && swaps.length > 0
452+
});
453+
454+
return objkts
455+
}
456+
457+
filterCreationsForSaleSecondary = async () => {
435458
let objkts = this.state.creations.filter(item => {
436459
const swaps = item.swaps.filter(swaps => {
437460
return swaps.status == 0
@@ -841,10 +864,18 @@ export default class Display extends Component {
841864
</Button>
842865
<Button
843866
onClick={() => {
844-
this.creationsForSale();
867+
this.creationsForSale(0);
868+
}}>
869+
<div className={styles.tag}>
870+
primary
871+
</div>
872+
</Button>
873+
<Button
874+
onClick={() => {
875+
this.creationsForSale(1);
845876
}}>
846877
<div className={styles.tag}>
847-
for sale
878+
secondary
848879
</div>
849880
</Button>
850881
<Button

0 commit comments

Comments
 (0)