Skip to content

Commit

Permalink
chore(devwallet): use createportal (#2634)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans authored Nov 5, 2024
1 parent 59e0dec commit 7908b69
Show file tree
Hide file tree
Showing 39 changed files with 1,151 additions and 1,096 deletions.
2 changes: 2 additions & 0 deletions .changeset/dull-kids-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 0 additions & 2 deletions packages/apps/dev-wallet/src/App/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
MonoWorkspaces,
} from '@kadena/kode-icons/system';

import { Aside } from '@/Components/Aside/Aside';
import { NetworkSelector } from '@/Components/NetworkSelector/NetworkSelector';
import { BreadCrumbs } from '@/pages/BreadCrumbs/BreadCrumbs';
import { Themes, useTheme } from '@kadena/kode-ui';
Expand Down Expand Up @@ -41,7 +40,6 @@ export const Layout: FC = () => {
return (
<>
<SideBarLayout
aside={<Aside />}
topBanner={<BetaHeader />}
breadcrumbs={<BreadCrumbs />}
location={innerLocation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function AccountInput({
/>
)}
<TextField
aria-label="Account"
startVisual={
<Stack gap={'sm'}>
<MonoAccountBalanceWallet />
Expand Down Expand Up @@ -90,7 +91,6 @@ export function AccountInput({
contract,
(key) => key,
);
console.log(accounts);
setDiscovering(false);
if (accounts.length > 1) {
setDiscoveredAccounts(accounts);
Expand Down
60 changes: 0 additions & 60 deletions packages/apps/dev-wallet/src/Components/Aside/Aside.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions packages/apps/dev-wallet/src/Components/Aside/views/AddContact.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions packages/apps/dev-wallet/src/Components/Aside/views/Error.tsx

This file was deleted.

91 changes: 0 additions & 91 deletions packages/apps/dev-wallet/src/Components/Aside/views/KeySource.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions packages/apps/dev-wallet/src/Components/Aside/views/NewAsset.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { useWallet } from '@/modules/wallet/wallet.hook';
import { queryAllChainsClient } from '@kadena/client-utils/core';
import { composePactCommand, execution } from '@kadena/client/fp';
import { Button, Notification, Stack, TextField } from '@kadena/kode-ui';
import { useLayout } from '@kadena/kode-ui/patterns';
import {
RightAside,
RightAsideContent,
RightAsideFooter,
RightAsideHeader,
useLayout,
} from '@kadena/kode-ui/patterns';
import { useState } from 'react';
import { useForm } from 'react-hook-form';

Expand All @@ -12,7 +18,7 @@ interface TokenForm {
symbol: string;
}

export function AddToken() {
export function AddTokenForm({ isOpen }: { isOpen: boolean }) {
const { register, handleSubmit } = useForm<TokenForm>({
defaultValues: {
contract: '',
Expand All @@ -21,7 +27,7 @@ export function AddToken() {
});

const { activeNetwork } = useWallet();
const { handleSetAsideExpanded } = useLayout();
const { setIsRightAsideExpanded } = useLayout();
const [error, setError] = useState<string | null>(null);

async function onSubmit(data: TokenForm) {
Expand Down Expand Up @@ -57,25 +63,42 @@ export function AddToken() {
} as const;

await accountRepository.addFungible(token);
handleSetAsideExpanded(false);
setIsRightAsideExpanded(false);
} catch (e: any) {

Check warning on line 67 in packages/apps/dev-wallet/src/Components/Assets/AddTokenForm.tsx

View workflow job for this annotation

GitHub Actions / Changelog PR or Release

Unexpected any. Specify a different type
setError(e?.message || e);
}
}

return (
<form onSubmit={handleSubmit(onSubmit)}>
<Stack flexDirection={'column'} gap={'md'}>
<TextField
label="SmartContract"
{...register('contract', { required: true })}
/>
<TextField label="Symbol" {...register('symbol', { required: true })} />
{error && <Notification role="alert">{error}</Notification>}
<Stack width="100%" justifyContent="flex-end" gap="md">
<RightAside isOpen={isOpen}>
<form onSubmit={handleSubmit(onSubmit)}>
<RightAsideHeader label="Add New Asset" />
<RightAsideContent>
<Stack width="100%" flexDirection="column" gap="md">
<TextField
label="SmartContract"
{...register('contract', { required: true })}
/>
<TextField
label="Symbol"
{...register('symbol', { required: true })}
/>
{error && <Notification role="alert">{error}</Notification>}
</Stack>
</RightAsideContent>
<RightAsideFooter>
<Button
variant="outlined"
onPress={() => {
setIsRightAsideExpanded(false);
}}
type="reset"
>
Cancel
</Button>
<Button type="submit">Add Token</Button>
</Stack>
</Stack>
</form>
</RightAsideFooter>
</form>
</RightAside>
);
}
Loading

0 comments on commit 7908b69

Please sign in to comment.