Skip to content

Commit

Permalink
fix(tangle-dapp): Hide withdraw button
Browse files Browse the repository at this point in the history
  • Loading branch information
yurixander committed Aug 25, 2024
1 parent 84a52ce commit 1d30caf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { useLiquidStakingStore } from '../../../data/liquidStaking/useLiquidStak
import useLiquifierNftUnlocks, {
LiquifierUnlockNftMetadata,
} from '../../../data/liquifier/useLiquifierNftUnlocks';
import useSubstrateAddress from '../../../hooks/useSubstrateAddress';
import useActiveAccountAddress from '../../../hooks/useActiveAccountAddress';
import addCommasToNumber from '../../../utils/addCommasToNumber';
import isLsErc20TokenId from '../../../utils/liquidStaking/isLsErc20TokenId';
import isLsParachainChainId from '../../../utils/liquidStaking/isLsParachainChainId';
Expand Down Expand Up @@ -85,11 +85,16 @@ const COLUMNS = [
COLUMN_HELPER.accessor('unlockId', {
header: () => <HeaderCell title="Unlock ID" className="justify-start" />,
cell: (props) => {
const canSelect =
props.row.original.type === 'liquifierUnlockNft'
? props.row.original.progress === 1
: true;

return (
<div className="flex items-center justify-start gap-2">
<CheckBox
isChecked={props.row.getIsSelected()}
isDisabled={!props.row.getCanSelect()}
isDisabled={!props.row.getCanSelect() || !canSelect}
onChange={props.row.getToggleSelectedHandler()}
wrapperClassName="pt-0.5 flex items-center justify-center"
/>
Expand Down Expand Up @@ -160,7 +165,7 @@ const COLUMNS = [

const UnstakeRequestsTable: FC = () => {
const { selectedProtocolId } = useLiquidStakingStore();
const substrateAddress = useSubstrateAddress();
const activeAccountAddress = useActiveAccountAddress();
const parachainRows = useLstUnlockRequestTableRows();
const evmRows = useLiquifierNftUnlocks();

Expand Down Expand Up @@ -202,7 +207,7 @@ const UnstakeRequestsTable: FC = () => {
// when the selected rows change.
const table = (() => {
// No account connected.
if (substrateAddress === null) {
if (activeAccountAddress === null) {
return (
<Notice
title="No account connected"
Expand Down Expand Up @@ -291,6 +296,9 @@ const UnstakeRequestsTable: FC = () => {
});
}, [selectedRows]);

const isDataState =
rows !== null && rows.length > 0 && activeAccountAddress !== null;

return (
<div className="space-y-4 flex-grow max-w-[700px]">
<GlassCard
Expand All @@ -302,7 +310,7 @@ const UnstakeRequestsTable: FC = () => {
>
{table}

{rows !== null && rows.length > 0 && (
{isDataState && (
<div className="flex gap-3 items-center justify-center">
{isLsParachainChainId(selectedProtocolId) && (
<RebondLstUnstakeRequestButton
Expand Down
9 changes: 8 additions & 1 deletion apps/tangle-dapp/data/liquifier/useLiquifierNftUnlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,21 @@ const useLiquifierNftUnlocks = (): LiquifierUnlockNftMetadata[] | null => {
// different unlock requests.
const unlockId = IS_PRODUCTION_ENV ? Number(metadata.unlockId) : index;

// On development, mark some as completed for testing purposes.
const progress = IS_PRODUCTION_ENV
? Number(metadata.progress) / 100
: index < 10
? 1
: 0.6123;

return {
type: 'liquifierUnlockNft',
decimals: protocol.decimals,
unlockId,
symbol: metadata.symbol,
name: metadata.name,
validator: metadata.validator,
progress: Number(metadata.progress) / 100,
progress,
amount: new BN(metadata.amount.toString()),
maturityTimestamp: Number(metadata.maturity),
} satisfies LiquifierUnlockNftMetadata;
Expand Down

0 comments on commit 1d30caf

Please sign in to comment.