Skip to content

Commit

Permalink
disable pausebutton for all except agent
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans committed Dec 10, 2024
1 parent bc878a4 commit 5342781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/apps/rwa-demo/src/app/(app)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SupplyCount } from '@/components/SupplyCount/SupplyCount';
import { TransferForm } from '@/components/TransferForm/TransferForm';
import { useAccount } from '@/hooks/account';
import { useAsset } from '@/hooks/asset';
import { useFreeze } from '@/hooks/freeze';
import { MonoAdd, MonoEditNote } from '@kadena/kode-icons';
import { Button, Stack } from '@kadena/kode-ui';
import {
Expand All @@ -21,6 +22,7 @@ import {

const Home = () => {
const { isInvestor, isComplianceOwner, account } = useAccount();
const { frozen } = useFreeze({ investorAccount: account?.address });
const { paused, asset } = useAsset();

return (
Expand Down Expand Up @@ -66,7 +68,7 @@ const Home = () => {
<TransferForm
trigger={
<AssetAction
isDisabled={paused || !isInvestor}
isDisabled={paused || frozen || !isInvestor}
icon={<MonoAdd />}
label="Transfer tokens"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useAccount } from '@/hooks/account';
import { useAsset } from '@/hooks/asset';
import { MonoPause, MonoPlayArrow } from '@kadena/kode-icons';
import { useState } from 'react';
Expand All @@ -7,6 +8,7 @@ import { PauseForm } from './PauseForm';

export const PauseAssetAction = () => {
const { paused } = useAsset();
const { isAgent } = useAccount();
const [loading, setLoading] = useState(false);

const showIcon = () => {
Expand All @@ -19,7 +21,13 @@ export const PauseAssetAction = () => {
return (
<PauseForm
handleSetIsLoading={setLoading}
trigger={<AssetAction icon={showIcon()} label="Contract is active" />}
trigger={
<AssetAction
isDisabled={!isAgent}
icon={showIcon()}
label="Contract is active"
/>
}
/>
);
};

0 comments on commit 5342781

Please sign in to comment.