Skip to content

Commit e63e635

Browse files
update owned filter
1 parent 02ffdd8 commit e63e635

File tree

4 files changed

+106
-31
lines changed

4 files changed

+106
-31
lines changed

components/ui/BeastMarket/BeastMarket.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,15 @@ const BeastMarket: FC<Props> = () => {
934934
}
935935
// setElementFilter((elementFilter: any) => [...elementFilter, "Electric"])
936936
setDisplayBeasts(newBeasts)
937+
} else if (ownedToggled) {
938+
var newBeasts: any = []
939+
for (let key in beasts) {
940+
var beast = beasts[key]
941+
if (userBeasts?.map((beast: any) => beast.id).includes(beast.id)) {
942+
newBeasts.push(beast)
943+
}
944+
}
945+
setDisplayBeasts(newBeasts)
937946
} else {
938947
setDisplayBeasts(beasts)
939948
}
@@ -951,6 +960,16 @@ const BeastMarket: FC<Props> = () => {
951960
}
952961
}
953962
setDisplayBeasts(newBeasts)
963+
} else if (favoriteToggled) {
964+
console.log(favoriteBeasts)
965+
var newBeasts: any = []
966+
for (let key in beasts) {
967+
var beast = beasts[key]
968+
if (favoriteBeasts.includes(beast.id)) {
969+
newBeasts.push(beast)
970+
}
971+
}
972+
setDisplayBeasts(newBeasts)
954973
} else {
955974
setDisplayBeasts(beasts)
956975
}

components/ui/BeastMarketFilters/BeastMarketFilters.tsx

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from "styled-components"
33
import { FC, Fragment, useEffect, useState } from "react"
44
import { Dialog, Disclosure, Menu, Transition } from "@headlessui/react"
55
import { ChevronDownIcon, MinusIcon, PlusIcon } from "@heroicons/react/solid"
6+
import { useAuth } from "@components/auth/AuthProvider"
67

78
const Wrapper = styled.div`
89
background: transparent;
@@ -177,6 +178,8 @@ const BeastMarketFilters: FC<Props> = ({
177178

178179
useEffect(() => {}, [filters])
179180

181+
const { loggedIn } = useAuth()
182+
180183
type SelectedFilters = {
181184
dexNumber: [number]
182185
skin: [string]
@@ -472,38 +475,61 @@ const BeastMarketFilters: FC<Props> = ({
472475
<h3 className="sr-only">Categories</h3>
473476
<ul role="list" className="pb-6 text-sm font-medium ">
474477
{subCategories.map((category) => (
475-
<li
476-
className="flex w-full justify-between items-center"
477-
key={category.name}
478-
>
479-
<a style={{ fontSize: "1.3em" }} href={category.href}>
480-
{category.name}
481-
</a>
482-
{category.name == "Favorites" && (
483-
<Switch>
484-
<SwitchInput
485-
defaultChecked={favoriteToggled}
486-
type="checkbox"
487-
onChange={() => {
488-
setFavoriteToggled(!favoriteToggled)
489-
}}
490-
/>
491-
<SwitchSlider></SwitchSlider>
492-
</Switch>
493-
)}
494-
{category.name == "Owned" && (
495-
<Switch>
496-
<SwitchInput
497-
defaultChecked={ownedToggled}
498-
type="checkbox"
499-
onChange={() => {
500-
setOwnedToggled(!ownedToggled)
501-
}}
502-
/>
503-
<SwitchSlider></SwitchSlider>
504-
</Switch>
478+
<>
479+
{category.name == "Owned" ? (
480+
<>
481+
{loggedIn && (
482+
<li
483+
className="flex w-full justify-between items-center"
484+
key={category.name}
485+
>
486+
<a
487+
style={{ fontSize: "1.3em" }}
488+
href={category.href}
489+
>
490+
{category.name}
491+
</a>
492+
{category.name == "Owned" && (
493+
<Switch>
494+
<SwitchInput
495+
defaultChecked={ownedToggled}
496+
type="checkbox"
497+
onChange={() => {
498+
setOwnedToggled(!ownedToggled)
499+
}}
500+
/>
501+
<SwitchSlider></SwitchSlider>
502+
</Switch>
503+
)}
504+
</li>
505+
)}
506+
</>
507+
) : (
508+
<li
509+
className="flex w-full justify-between items-center"
510+
key={category.name}
511+
>
512+
<a
513+
style={{ fontSize: "1.3em" }}
514+
href={category.href}
515+
>
516+
{category.name}
517+
</a>
518+
{category.name == "Favorites" && (
519+
<Switch>
520+
<SwitchInput
521+
defaultChecked={favoriteToggled}
522+
type="checkbox"
523+
onChange={() => {
524+
setFavoriteToggled(!favoriteToggled)
525+
}}
526+
/>
527+
<SwitchSlider></SwitchSlider>
528+
</Switch>
529+
)}
530+
</li>
505531
)}
506-
</li>
532+
</>
507533
))}
508534
</ul>
509535
{ownedToggled || favoriteToggled ? (

framework/hooks/use-user-inbox.hook.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default function useInbox(user: any) {
7575
import Pack from 0xPack
7676
import NonFungibleToken from 0xNonFungibleToken
7777
import MetadataViews from 0xMetadataViews
78+
import FUSD from 0xFUSD
7879
7980
pub fun hasPackCollection(_ address: Address): Bool {
8081
return getAccount(address)
@@ -90,6 +91,26 @@ export default function useInbox(user: any) {
9091
9192
prepare(acct: AuthAccount) {
9293
94+
// check for FUSD vault
95+
if acct.borrow<&FUSD.Vault>(from: /storage/fusdVault) == nil {
96+
// Create a new FUSD Vault and put it in storage
97+
acct.save(<-FUSD.createEmptyVault(), to: /storage/fusdVault)
98+
99+
// Create a public capability to the Vault that only exposes
100+
// the deposit function through the Receiver interface
101+
acct.link<&FUSD.Vault{FungibleToken.Receiver}>(
102+
/public/fusdReceiver,
103+
target: /storage/fusdVault
104+
)
105+
106+
// Create a public capability to the Vault that only exposes
107+
// the balance field through the Balance interface
108+
acct.link<&FUSD.Vault{FungibleToken.Balance}>(
109+
/public/fusdBalance,
110+
target: /storage/fusdVault
111+
)
112+
}
113+
93114
self.centralizedInboxRef = getAccount(adminAcct).getCapability(Inbox.CentralizedInboxPublicPath)
94115
.borrow<&Inbox.CentralizedInbox{Inbox.Public}>()
95116
?? panic("Could not get Centralized Inbox reference")

pages/evolution.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import type { NextPage } from "next"
22
import DefaultHeroSection from "@components/ui/DefaultHeroSection"
3+
import EvolutionModal from "@components/ui/EvolutionModal"
4+
import { useState } from "react"
35

46
const Evolution: NextPage = () => {
7+
const [open, setOpen] = useState(true)
58
return (
69
<div>
710
<DefaultHeroSection
811
title="Coming Soon!"
912
description="Evolve your Basic Beasts to complete your Dexicon"
1013
/>
14+
<EvolutionModal
15+
handleClose={() => setOpen(true)}
16+
RevealModalOpen={open}
17+
packId={"1" || "1"}
18+
evolvedBeastId={"2"}
19+
/>
1120
</div>
1221
)
1322
}

0 commit comments

Comments
 (0)