-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated navigation from vaults, copy to clipboard hook added
- Loading branch information
1 parent
bed76a2
commit c9e4aec
Showing
9 changed files
with
140 additions
and
54 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
50 changes: 38 additions & 12 deletions
50
...vault/components/vault-expanded-information/components/vault-expanded-information-row.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
61 changes: 50 additions & 11 deletions
61
...app/components/vault/components/vault-expanded-information/vault-expanded-information.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 |
---|---|---|
@@ -1,38 +1,77 @@ | ||
import { Divider, ScaleFade, Stack, VStack } from '@chakra-ui/react'; | ||
import { easyTruncateAddress } from '@common/utilities'; | ||
import { useDispatch } from 'react-redux'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { VaultExpandedInformationRow } from './components/vault-expanded-information-row'; | ||
import { Button, Divider, SlideFade, Stack, VStack } from '@chakra-ui/react'; | ||
import { VaultState } from '@models/vault'; | ||
import { mintUnmintActions } from '@store/slices/mintunmint/mintunmint.actions'; | ||
|
||
import { VaultExpandedInformationUUIDRow } from './components/vault-expanded-information-row'; | ||
import { VaultExpandedInformationTransactionRow } from './components/vault-expanded-information-transaction-row'; | ||
|
||
interface VaultExpandedInformationProps { | ||
uuid: string; | ||
state: VaultState; | ||
fundingTX: string; | ||
closingTX: string; | ||
isExpanded: boolean; | ||
isSelected?: boolean; | ||
close: () => void; | ||
} | ||
|
||
export function VaultExpandedInformation({ | ||
uuid, | ||
state, | ||
fundingTX, | ||
closingTX, | ||
isExpanded, | ||
isSelected, | ||
close, | ||
}: VaultExpandedInformationProps): React.JSX.Element { | ||
const navigate = useNavigate(); | ||
const dispatch = useDispatch(); | ||
|
||
return ( | ||
<Stack w={'100%'}> | ||
<ScaleFade in={isExpanded} unmountOnExit> | ||
<SlideFade in={isExpanded} unmountOnExit> | ||
<VStack> | ||
<Divider w={'100%'} borderStyle={'dashed'} /> | ||
<VStack w={'100%'} justifyContent={'space-between'}> | ||
<VaultExpandedInformationRow label={'UUID'} value={easyTruncateAddress(uuid)} /> | ||
{Boolean(fundingTX) && ( | ||
<VaultExpandedInformationTransactionRow label={'Funding TX'} value={fundingTX} /> | ||
<VStack w={'100%'} spacing={'25px'}> | ||
<VStack w={'100%'} justifyContent={'space-between'}> | ||
<VaultExpandedInformationUUIDRow uuid={uuid} /> | ||
{Boolean(fundingTX) && ( | ||
<VaultExpandedInformationTransactionRow label={'Funding TX'} value={fundingTX} /> | ||
)} | ||
{Boolean(closingTX) && ( | ||
<VaultExpandedInformationTransactionRow label={'Closing TX'} value={closingTX} /> | ||
)} | ||
</VStack> | ||
{state === VaultState.READY && !isSelected && ( | ||
<Button | ||
onClick={() => { | ||
navigate('/'); | ||
dispatch(mintUnmintActions.setMintStep([1, uuid])); | ||
close(); | ||
}} | ||
variant={'account'} | ||
> | ||
Lock BTC | ||
</Button> | ||
)} | ||
{Boolean(closingTX) && ( | ||
<VaultExpandedInformationTransactionRow label={'Closing TX'} value={closingTX} /> | ||
{state === VaultState.FUNDED && !isSelected && ( | ||
<Button | ||
onClick={() => { | ||
navigate('/'); | ||
dispatch(mintUnmintActions.setUnmintStep([0, uuid])); | ||
close(); | ||
}} | ||
variant={'account'} | ||
> | ||
Redeem dlcBTC | ||
</Button> | ||
)} | ||
</VStack> | ||
</VStack> | ||
</ScaleFade> | ||
</SlideFade> | ||
</Stack> | ||
); | ||
} |
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,21 @@ | ||
import { useState } from 'react'; | ||
|
||
interface UseCopyToClipboardReturnType { | ||
hasCopied: boolean; | ||
copyToClipboard: (text: string) => Promise<void>; | ||
} | ||
|
||
export function useCopyToClipboard(): UseCopyToClipboardReturnType { | ||
const [hasCopied, setHasCopied] = useState(false); | ||
|
||
async function copyToClipboard(text: string) { | ||
await navigator.clipboard.writeText(text); | ||
setHasCopied(true); | ||
setTimeout(() => setHasCopied(false), 2500); | ||
} | ||
|
||
return { | ||
hasCopied, | ||
copyToClipboard, | ||
}; | ||
} |
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