-
Notifications
You must be signed in to change notification settings - Fork 27
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
1 parent
869bb18
commit b83bb5f
Showing
6 changed files
with
323 additions
and
88 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
packages/apps/rwa-demo/src/components/BadgeFeezeForm/BadgeFeezeForm.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,67 @@ | ||
import { useBatchFreezeInvestors } from '@/hooks/batchFreezeInvestors'; | ||
import type { IBatchSetAddressFrozenProps } from '@/services/batchSetAddressFrozen'; | ||
import { MonoPause, MonoPlayArrow } from '@kadena/kode-icons'; | ||
import { Button } from '@kadena/kode-ui'; | ||
|
||
import { useAccount } from '@/hooks/account'; | ||
import type { FC } from 'react'; | ||
import type { UseFormHandleSubmit, UseFormReset } from 'react-hook-form'; | ||
import { TransactionTypeSpinner } from '../TransactionTypeSpinner/TransactionTypeSpinner'; | ||
import { TXTYPES } from '../TransactionsProvider/TransactionsProvider'; | ||
|
||
interface IProps { | ||
pause: boolean; | ||
isDisabled: boolean; | ||
handleReset: UseFormReset<{ | ||
select: []; | ||
}>; | ||
handleSubmit: UseFormHandleSubmit< | ||
{ | ||
select: []; | ||
}, | ||
undefined | ||
>; | ||
} | ||
|
||
export const BadgeFreezeForm: FC<IProps> = ({ | ||
handleSubmit, | ||
handleReset, | ||
isDisabled, | ||
pause, | ||
}) => { | ||
const { account } = useAccount(); | ||
const { submit, isAllowed } = useBatchFreezeInvestors(); | ||
|
||
const onSubmit = async ({ select }: { select: string[] }) => { | ||
const data: IBatchSetAddressFrozenProps = { | ||
investorAccounts: select, | ||
pause, | ||
}; | ||
const tx = await submit(data); | ||
tx?.listener.subscribe( | ||
() => {}, | ||
() => {}, | ||
() => { | ||
handleReset({ select: [] }); | ||
}, | ||
); | ||
}; | ||
|
||
return ( | ||
<Button | ||
isDisabled={isDisabled || !isAllowed} | ||
onClick={handleSubmit(onSubmit)} | ||
isCompact | ||
variant="outlined" | ||
endVisual={ | ||
<TransactionTypeSpinner | ||
type={[TXTYPES.FREEZEINVESTOR]} | ||
account={account?.address} | ||
fallbackIcon={pause ? <MonoPlayArrow /> : <MonoPause />} | ||
/> | ||
} | ||
> | ||
{pause ? 'Freeze' : 'Unfreeze'} | ||
</Button> | ||
); | ||
}; |
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
26 changes: 26 additions & 0 deletions
26
packages/apps/rwa-demo/src/components/TableFormatters/FormatCheckbox.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,26 @@ | ||
import type { ICompactTableFormatterProps } from '@kadena/kode-ui/patterns'; | ||
import React from 'react'; | ||
import type { UseFormRegister } from 'react-hook-form'; | ||
|
||
export interface IActionProps { | ||
name: 'select'; | ||
register: UseFormRegister<{ | ||
select: []; | ||
}>; | ||
} | ||
|
||
export const FormatCheckbox = ({ name, register }: IActionProps) => { | ||
const Component = ({ value }: ICompactTableFormatterProps) => { | ||
return ( | ||
<input | ||
{...register(name, {})} | ||
type="checkbox" | ||
name={name} | ||
data-value={value} | ||
id={name} | ||
value={value} | ||
/> | ||
); | ||
}; | ||
return Component; | ||
}; |
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.