forked from dapperlabs/kitty-items-web
-
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.
general styles and pages and routes and stuff
- Loading branch information
Showing
20 changed files
with
1,475 additions
and
197 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {config} from "@onflow/fcl" | ||
|
||
const CONTRACTS = "0xfcceff21d9532b58" | ||
|
||
config() | ||
.put("env", "testnet") | ||
.put("accessNode.api", "https://access-testnet.onflow.org") | ||
.put("challenge.handshake", "https://fcl-discovery.vercel.app/testnet/authn") | ||
.put("0xFungibleToken", "0x9a0766d93b6608b7") | ||
.put("0xNonFungibleToken", "0x631e88ae7f1d7c20") | ||
.put("0xKibble", CONTRACTS) | ||
.put("0xKittyItemsMarket", CONTRACTS) | ||
.put("0xKittyItems", CONTRACTS) |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {withPrefix} from "@onflow/fcl" | ||
import {useParams} from "react-router-dom" | ||
|
||
export function useAddress() { | ||
const {address} = useParams() | ||
return withPrefix(address) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import {Suspense} from "react" | ||
import {Base} from "../../parts/base.comp" | ||
import {IDLE} from "../../global/constants" | ||
import {useAddress} from "../../hooks/use-url-address.hook" | ||
import {useCurrentUser} from "../../hooks/use-current-user.hook" | ||
import {useMarketItems} from "../../hooks/use-market-items.hook" | ||
import {useAccountItems} from "../../hooks/use-account-items.hook" | ||
import AuthCluster from "../../parts/auth-cluster.comp" | ||
import InitCluster from "../../parts/init-cluster.comp" | ||
import BalanceCluster from "../../parts/balance-cluster.comp" | ||
import MarketItemsCluster from "../../parts/market-items-cluster.comp" | ||
import AccountItemsCluster from "../../parts/account-items-cluster.comp" | ||
import { | ||
Box, | ||
Flex, | ||
Center, | ||
Heading, | ||
Tag, | ||
Text, | ||
Tabs, | ||
TabList, | ||
Tab, | ||
TabPanels, | ||
TabPanel, | ||
Spinner, | ||
} from "@chakra-ui/react" | ||
|
||
const STORE_ADDRESS = "0xba1132bc08f82fe2" | ||
|
||
export function MarketItemsCount({address}) { | ||
const items = useMarketItems(address) | ||
if (items.status !== IDLE) return <Spinner size="xs" ml="1" /> | ||
const l = items?.ids?.length ?? 0 | ||
return l > 0 ? <Tag ml="1">{l}</Tag> : null | ||
} | ||
|
||
export function AccountItemsCount({address}) { | ||
const items = useAccountItems(address) | ||
if (items.status !== IDLE) return <Spinner size="xs" ml="1" /> | ||
const l = items?.ids?.length ?? 0 | ||
return l > 0 ? <Tag ml="1">{l}</Tag> : null | ||
} | ||
|
||
export function StoreItemsCount() { | ||
const items = useAccountItems(STORE_ADDRESS) | ||
if (items.status !== IDLE) return <Spinner size="xs" ml="1" /> | ||
const l = items?.ids?.length ?? 0 | ||
return l > 0 ? <Tag ml="1">{l}</Tag> : null | ||
} | ||
|
||
export function Page() { | ||
const address = useAddress() | ||
const [cu] = useCurrentUser() | ||
if (address == null) return <div>Not Found</div> | ||
|
||
return ( | ||
<Base> | ||
<Box p="4"> | ||
<AuthCluster /> | ||
<Flex mb="4"> | ||
<Center> | ||
<Text mr="4" fontSize="3xl" color="purple.500"> | ||
Account: | ||
</Text> | ||
</Center> | ||
<Heading>{address}</Heading> | ||
{address === cu.addr && ( | ||
<Center> | ||
<Tag ml="4" variant="outline" colorScheme="orange"> | ||
You | ||
</Tag> | ||
</Center> | ||
)} | ||
</Flex> | ||
<Flex> | ||
<Box> | ||
<InitCluster address={address} /> | ||
</Box> | ||
<Box ml="4"> | ||
<BalanceCluster address={address} /> | ||
</Box> | ||
</Flex> | ||
<Tabs> | ||
<TabList> | ||
<Tab> | ||
For Sale{" "} | ||
<Suspense fallback={null}> | ||
<MarketItemsCount address={address} /> | ||
</Suspense> | ||
</Tab> | ||
<Tab> | ||
Items | ||
<Suspense fallback={null}> | ||
<AccountItemsCount address={address} /> | ||
</Suspense> | ||
</Tab> | ||
{cu.addr === address && ( | ||
<Tab> | ||
Store | ||
<Suspense fallback={null}> | ||
<StoreItemsCount address={address} /> | ||
</Suspense> | ||
</Tab> | ||
)} | ||
</TabList> | ||
|
||
<TabPanels> | ||
<TabPanel> | ||
<MarketItemsCluster address={address} /> | ||
</TabPanel> | ||
<TabPanel> | ||
<AccountItemsCluster address={address} /> | ||
</TabPanel> | ||
{cu.addr === address && ( | ||
<TabPanel> | ||
<MarketItemsCluster address={STORE_ADDRESS} /> | ||
</TabPanel> | ||
)} | ||
</TabPanels> | ||
</Tabs> | ||
</Box> | ||
</Base> | ||
) | ||
} |
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,5 +1,29 @@ | ||
import {Base} from "../parts/base.comp" | ||
import {useCurrentUser} from "../hooks/use-current-user.hook" | ||
import {Redirect} from "react-router-dom" | ||
import {Box, Button, Flex, Center, Heading, Spacer} from "@chakra-ui/react" | ||
|
||
export function Page() { | ||
return <Base>Page: Root</Base> | ||
const [user, loggedIn, {signUp, logIn, logOut}] = useCurrentUser() | ||
|
||
if (loggedIn) return <Redirect to={"/" + user.addr} /> | ||
|
||
return ( | ||
<Base> | ||
<Box p="4"> | ||
<Flex> | ||
<Center mr="4"> | ||
<Heading size="md">Kitty Items</Heading> | ||
</Center> | ||
<Spacer /> | ||
<Button mr="4" colorScheme="blue" onClick={logIn}> | ||
Log In | ||
</Button> | ||
<Button mr="4" colorScheme="blue" onClick={signUp}> | ||
Sign Up | ||
</Button> | ||
</Flex> | ||
</Box> | ||
</Base> | ||
) | ||
} |
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
Oops, something went wrong.