Skip to content

Commit

Permalink
Allow claim action for every logged in person
Browse files Browse the repository at this point in the history
  • Loading branch information
alicjakujawa committed Aug 18, 2021
1 parent f0f2153 commit a7d3cd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const MSG = defineMessages({
},
});

const UnclaimedTransfers = ({ colony: { colonyAddress }, colony }: Props) => {
const UnclaimedTransfers = ({ colony: { colonyAddress } }: Props) => {
const { data, error, loading } = useColonyTransfersQuery({
variables: { address: colonyAddress },
});
Expand All @@ -51,7 +51,6 @@ const UnclaimedTransfers = ({ colony: { colonyAddress }, colony }: Props) => {
<UnclaimedTransfersItem
transaction={transaction}
key={transaction.hash}
colony={colony}
/>
))}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ import {
ColonyTransaction,
useUsernameQuery,
useLoggedInUser,
Colony,
} from '~data/index';
import { ActionTypes } from '~redux/index';
import { mergePayload } from '~utils/actions';
import { useTransformer } from '~utils/hooks';
import { getTokenDecimalsWithFallback } from '~utils/tokens';
import { tokenIsETH } from '../../../core/checks';
import { hasRoot } from '../../../users/checks';
import { getAllUserRoles } from '../../../transformers';

import { ALLOWED_NETWORKS } from '~constants';

Expand All @@ -45,7 +41,6 @@ const MSG = defineMessages({

interface Props {
transaction: ColonyTransaction;
colony: Colony;
}

const UnclaimedTransfersItem = ({
Expand All @@ -56,9 +51,10 @@ const UnclaimedTransfersItem = ({
token: tokenAddress,
from: senderAddress,
},
colony,
}: Props) => {
const { username, walletAddress, networkId, ethereal } = useLoggedInUser();
const { networkId, ethereal, username } = useLoggedInUser();

const hasRegisteredProfile = !!username && !ethereal;

const { data: tokenData } = useTokenQuery({
variables: { address: tokenAddress },
Expand All @@ -76,10 +72,6 @@ const UnclaimedTransfersItem = ({
const senderUsername = usernameData && usernameData.username;
const description = null; // Will be support after network upgrade to v5

const hasRegisteredProfile = !!username && !ethereal;
const allUserRoles = useTransformer(getAllUserRoles, [colony, walletAddress]);
const userHasPermission = hasRegisteredProfile && hasRoot(allUserRoles);

const isNetworkAllowed = !!ALLOWED_NETWORKS[networkId || 1];

if (!tokenData) return null;
Expand Down Expand Up @@ -136,7 +128,7 @@ const UnclaimedTransfersItem = ({
error={ActionTypes.COLONY_CLAIM_TOKEN_ERROR}
success={ActionTypes.COLONY_CLAIM_TOKEN_SUCCESS}
transform={transform}
disabled={!userHasPermission || !isNetworkAllowed}
disabled={!isNetworkAllowed || !hasRegisteredProfile}
/>
</div>
</li>
Expand Down

0 comments on commit a7d3cd2

Please sign in to comment.