-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
191 additions
and
21 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,27 @@ | ||
import { | ||
AbstractAccountId, | ||
AccountProvider, | ||
} from '@abstract-money/abstract.js-react' | ||
import type { FC } from 'react' | ||
import { Outlet, useParams } from 'react-router-dom' | ||
import Page404 from '~/lib/pages/404' | ||
import { type AccountIdParams } from '~/lib/router/routeParams' | ||
|
||
interface AccountLayoutProps {} | ||
|
||
/** | ||
* Provide the account to the nested routes. | ||
*/ | ||
export const AccountLayout: FC<AccountLayoutProps> = () => { | ||
const { accountId } = useParams<AccountIdParams>() | ||
|
||
if (!accountId) { | ||
return <Page404 what={`Account ${accountId}`} /> | ||
} | ||
|
||
return ( | ||
<AccountProvider accountId={AbstractAccountId.fromStringId(accountId)}> | ||
<Outlet /> | ||
</AccountProvider> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
useAccount, | ||
useManagerInfoQuery, | ||
} from '@abstract-money/abstract.js-react' | ||
import { useAbstractQueryClient } from '@abstract-money/abstract.js-react/lib/hooks' | ||
import { Flex, Heading, Skeleton, Text } from '@chakra-ui/react' | ||
|
||
const AccountHome = () => { | ||
const { accountQueryClient, accountId } = useAccount() | ||
const { data: test } = useAbstractQueryClient({ chainName: 'junotestnet' }) | ||
|
||
console.log(accountQueryClient, test) | ||
|
||
// Use a raw query on the account | ||
const { data: accountInfo } = useManagerInfoQuery({ | ||
client: accountQueryClient?.managerQueryClient, | ||
options: { | ||
select: ({ info }) => info, | ||
}, | ||
}) | ||
|
||
return ( | ||
<Flex> | ||
<Heading>{accountId.toStringId()}</Heading> | ||
<Text>{JSON.stringify(accountInfo || {})}</Text> | ||
|
||
<Skeleton isLoaded={!!accountInfo}> | ||
<Text>{accountInfo?.name}</Text> | ||
</Skeleton> | ||
</Flex> | ||
) | ||
} | ||
|
||
export default AccountHome |
55 changes: 55 additions & 0 deletions
55
packages/webapp/src/lib/pages/home/components/AccountInput.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,55 @@ | ||
import { AbstractAccountId } from '@abstract-money/abstract.js-react' | ||
import { | ||
Button, | ||
Input, | ||
InputGroup, | ||
InputRightElement, | ||
useToast, | ||
} from '@chakra-ui/react' | ||
import type React from 'react' | ||
import { useCallback, useState } from 'react' | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
export const AccountInput = () => { | ||
const [accountId, setAccountId] = useState('') | ||
const navigate = useNavigate() | ||
const toast = useToast() | ||
|
||
const validate = useCallback(() => { | ||
try { | ||
AbstractAccountId.fromStringId(accountId) | ||
return true | ||
} catch { | ||
return false | ||
} | ||
}, [accountId, toast]) | ||
|
||
const handleInputChange = useCallback( | ||
(e: { target: { value: React.SetStateAction<string> } }) => { | ||
setAccountId(e.target.value) | ||
}, | ||
[] | ||
) | ||
|
||
const handleClick = useCallback(() => { | ||
if (validate()) { | ||
navigate(`/account/${accountId}`) | ||
} | ||
}, [accountId, navigate, validate]) | ||
|
||
return ( | ||
<InputGroup size="md"> | ||
<Input | ||
aria-label="Account ID" | ||
placeholder="Account Id" | ||
value={accountId} | ||
onChange={handleInputChange} | ||
/> | ||
<InputRightElement width="4.5rem"> | ||
<Button h="1.75rem" size="sm" onClick={handleClick}> | ||
Search | ||
</Button> | ||
</InputRightElement> | ||
</InputGroup> | ||
) | ||
} |
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
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,3 @@ | ||
export type AccountIdParams = { | ||
accountId: string | ||
} |
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