Skip to content

Commit

Permalink
chore(rwa): cleanup (#2722)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans authored Dec 11, 2024
1 parent fa2cd31 commit 84a1c53
Show file tree
Hide file tree
Showing 35 changed files with 626 additions and 290 deletions.
2 changes: 2 additions & 0 deletions .changeset/tricky-schools-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
20 changes: 20 additions & 0 deletions packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use client';

import { InvestorList } from '@/components/InvestorList/InvestorList';
import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs';
import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns';

const AgentsPage = () => {
return (
<>
<SideBarBreadcrumbs>
<SideBarBreadcrumbsItem href="/investors">
Investors
</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>
<InvestorList />
</>
);
};

export default AgentsPage;
23 changes: 22 additions & 1 deletion packages/apps/rwa-demo/src/app/(app)/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { useAccount } from '@/hooks/account';
import {
MonoAccountBox,
MonoApps,
MonoAttachMoney,
MonoDarkMode,
MonoLightMode,
MonoLogout,
MonoNetworkCheck,
MonoSupportAgent,
MonoVpnLock,
} from '@kadena/kode-icons';
import {
Expand All @@ -31,7 +33,8 @@ import { KLogo } from './KLogo';
export const SideBar: FC = () => {
const { theme, setTheme } = useTheme();
const { isExpanded } = useLayout();
const { logout, account, isMounted } = useAccount();
const { logout, account, isMounted, isAgent, isOwner, isComplianceOwner } =
useAccount();
const router = useRouter();

const toggleTheme = (): void => {
Expand Down Expand Up @@ -68,6 +71,24 @@ export const SideBar: FC = () => {
component={Link}
href="/"
/>

{(isOwner || isAgent) && (
<SideBarItem
visual={<MonoSupportAgent />}
label="Agents"
component={Link}
href="/agents"
/>
)}
{(isAgent || isOwner || isComplianceOwner) && (
<SideBarItem
visual={<MonoAttachMoney />}
label="Investors"
component={Link}
href="/investors"
/>
)}

<SideBarItem
visual={<MonoVpnLock />}
label="Assets"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const InvestorPage = () => {
return (
<>
<SideBarBreadcrumbs>
<SideBarBreadcrumbsItem href="/agents">Agents</SideBarBreadcrumbsItem>

<SideBarBreadcrumbsItem href={`/agents/${agentAccount}`}>
Agent
{agent.alias}
</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>

Expand Down
18 changes: 18 additions & 0 deletions packages/apps/rwa-demo/src/app/(app)/agents/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import { AgentsList } from '@/components/AgentsList/AgentsList';
import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs';
import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns';

const AgentsPage = () => {
return (
<>
<SideBarBreadcrumbs>
<SideBarBreadcrumbsItem href="/agents">Agents</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>
<AgentsList />
</>
);
};

export default AgentsPage;
16 changes: 15 additions & 1 deletion packages/apps/rwa-demo/src/app/(app)/assets/[uuid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import type { IWalletAccount } from '@/components/AccountProvider/utils';
import type { IAsset } from '@/components/AssetProvider/AssetProvider';
import { useAccount } from '@/hooks/account';
import { useAsset } from '@/hooks/asset';
import {
SideBarBreadcrumbs,
SideBarBreadcrumbsItem,
} from '@kadena/kode-ui/patterns';
import { useParams } from 'next/navigation';
import { useEffect, useState } from 'react';

Expand All @@ -23,6 +27,16 @@ const Assets = () => {
initData(uuid as string, account);
}, [uuid, account?.address]);

return <pre>{JSON.stringify(asset, null, 2)}</pre>;
return (
<>
<SideBarBreadcrumbs>
<SideBarBreadcrumbsItem href="/assets">Assets</SideBarBreadcrumbsItem>
<SideBarBreadcrumbsItem href={`/assets/${asset?.uuid}`}>
Assets
</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>
<pre>{JSON.stringify(asset, null, 2)}</pre>
</>
);
};
export default Assets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use client';
import { useAsset } from '@/hooks/asset';
import { Heading, Stack, Text } from '@kadena/kode-ui';
import { useParams } from 'next/navigation';
import { useEffect, useState } from 'react';

const CreateAssetPage = () => {
const { setAsset, addExistingAsset } = useAsset();
const [isFound, setIsFound] = useState<boolean | undefined>(undefined);

const { namespace, contractName } = useParams();

useEffect(() => {
if (!namespace || !contractName) return;

const asset = addExistingAsset(`${namespace}.${contractName}`);
if (!asset) {
setIsFound(false);
return;
}
setTimeout(() => {
setAsset(asset);
}, 3000);
setIsFound(true);
}, [namespace, contractName]);

if (isFound === undefined) return null;

return (
<Stack
width="100%"
alignItems="center"
flexDirection="column"
gap="md"
marginBlockStart="xxxl"
>
<Heading>
{isFound ? 'The asset is found' : 'The asset is Not found'}
</Heading>
<Text>You will be redirected to the dashboard</Text>
</Stack>
);
};
export default CreateAssetPage;
37 changes: 29 additions & 8 deletions packages/apps/rwa-demo/src/app/(app)/assets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client';

import { AssetForm } from '@/components/AssetForm/AssetForm';
import { AssetFormScreen } from '@/components/AssetForm/AssetFormScreen';
import { Confirmation } from '@/components/Confirmation/Confirmation';
import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs';
import { useAsset } from '@/hooks/asset';
import { MonoAdd, MonoDelete } from '@kadena/kode-icons';
import { MonoAdd, MonoDelete, MonoFindInPage } from '@kadena/kode-icons';
import { Button } from '@kadena/kode-ui';
import {
CompactTable,
Expand All @@ -15,22 +16,31 @@ import {
SectionCardBody,
SectionCardContentBlock,
SectionCardHeader,
SideBarBreadcrumbsItem,
useLayout,
} from '@kadena/kode-ui/patterns';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useState } from 'react';

const Assets = () => {
const { assets, removeAsset } = useAsset();
const [openSide, setOpenSide] = useState(false);
const router = useRouter();
const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout();

const handleDelete = (value: any) => {
removeAsset(value);
};

const handleLink = async (uuid: any) => {
router.push(`/assets/${uuid}`);
};

return (
<>
<SideBarBreadcrumbs>
<SideBarBreadcrumbsItem href="/assets">Assets</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>
{isRightAsideExpanded && openSide && (
<RightAside
isOpen
Expand All @@ -49,7 +59,7 @@ const Assets = () => {
title="Assets"
description={<>List of all your selected contracts</>}
actions={
<AssetForm
<AssetFormScreen
trigger={
<Button variant="outlined" isCompact endVisual={<MonoAdd />}>
Add Asset
Expand All @@ -64,10 +74,21 @@ const Assets = () => {
{
key: 'contractName',
label: 'name',
width: '90%',
render: CompactTableFormatters.FormatLink({
linkComponent: Link,
url: '/assets/:value',
width: '80%',
},
{
label: '',
key: 'uuid',
width: '10%',
render: CompactTableFormatters.FormatActions({
trigger: (
<Button
isCompact
variant="outlined"
startVisual={<MonoFindInPage />}
onPress={handleLink}
/>
),
}),
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/rwa-demo/src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@kadena/kode-ui/patterns';

import { ActiveTransactionsList } from '@/components/ActiveTransactionsList/ActiveTransactionsList';
import { StepperAssetForm } from '@/components/AssetForm/StepperAssetForm';
import { AssetStepperForm } from '@/components/AssetForm/AssetStepperForm';
import { AssetInfo } from '@/components/AssetInfo/AssetInfo';
import { TransactionPendingIcon } from '@/components/TransactionPendingIcon/TransactionPendingIcon';
import { useAccount } from '@/hooks/account';
Expand Down Expand Up @@ -58,7 +58,7 @@ const RootLayout = ({
>
<div>
<Heading>Add new asset</Heading>
<StepperAssetForm />
<AssetStepperForm />
</div>
</Stack>
);
Expand Down
Loading

0 comments on commit 84a1c53

Please sign in to comment.