|
| 1 | +'use client'; |
| 2 | +import { useAppDispatch, useAppSelector } from '@/custom-hooks/StateHooks'; |
| 3 | +import { RootState } from '@/store/store'; |
| 4 | +import { useParams } from 'next/navigation'; |
| 5 | +import React from 'react'; |
| 6 | +import UserActionsList from '../components/UserActionsList'; |
| 7 | +import '../styles.css'; |
| 8 | +import EmptyScreen from '@/components/common/EmptyScreen'; |
| 9 | +import { setConnectWalletOpen } from '@/store/features/wallet/walletSlice'; |
| 10 | +import PageHeader from '@/components/common/PageHeader'; |
| 11 | + |
| 12 | +const ChainProposals = () => { |
| 13 | + const dispatch = useAppDispatch(); |
| 14 | + const params = useParams(); |
| 15 | + const paramChain = params.network; |
| 16 | + const chainName = typeof paramChain === 'string' ? paramChain : ''; |
| 17 | + const nameToChainIDs = useAppSelector( |
| 18 | + (state: RootState) => state.common.nameToChainIDs |
| 19 | + ); |
| 20 | + const isWalletConnected = useAppSelector((state) => state.wallet.connected); |
| 21 | + |
| 22 | + let chainID: string = ''; |
| 23 | + Object.keys(nameToChainIDs).forEach((chain) => { |
| 24 | + if (chain === chainName) chainID = nameToChainIDs[chain]; |
| 25 | + }); |
| 26 | + const connectWalletOpen = () => { |
| 27 | + dispatch(setConnectWalletOpen(true)); |
| 28 | + }; |
| 29 | + return ( |
| 30 | + <> |
| 31 | + {chainID.length ? ( |
| 32 | + <> |
| 33 | + {!isWalletConnected ? ( |
| 34 | + <div className="py-10"> |
| 35 | + <PageHeader |
| 36 | + title="Valoren" |
| 37 | + description="Cosmos stake management : Auto Restake and Auto Redelegate" |
| 38 | + /> |
| 39 | + <div className="mt-16"> |
| 40 | + <EmptyScreen |
| 41 | + title="Connect your wallet" |
| 42 | + description="Connect your wallet to access your account on Resolute" |
| 43 | + hasActionBtn={true} |
| 44 | + btnText={'Connect Wallet'} |
| 45 | + btnOnClick={connectWalletOpen} |
| 46 | + /> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + ) : ( |
| 50 | + <div className="py-10 h-full"> |
| 51 | + <UserActionsList chainID={chainID} /> |
| 52 | + </div> |
| 53 | + )} |
| 54 | + </> |
| 55 | + ) : ( |
| 56 | + <div className="w-full h-full flex justify-center items-center"> |
| 57 | + - Chain Not found - |
| 58 | + </div> |
| 59 | + )} |
| 60 | + </> |
| 61 | + ); |
| 62 | +}; |
| 63 | + |
| 64 | +export default ChainProposals; |
0 commit comments