2024-01-31 14:21:29 +00:00
|
|
|
import { useT } from '../../lib/use-t';
|
2024-02-20 12:20:35 +00:00
|
|
|
import { type EnrichedRewardTransfer } from '../../lib/hooks/use-rewards';
|
2024-03-15 16:41:48 +00:00
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet-react';
|
|
|
|
import { useStakeAvailable } from '../../lib/hooks/use-stake-available';
|
|
|
|
import { useMyTeam } from '../../lib/hooks/use-my-team';
|
|
|
|
import { ActiveRewardCard } from '../rewards-container/reward-card';
|
2024-01-31 14:21:29 +00:00
|
|
|
|
|
|
|
export const GamesContainer = ({
|
|
|
|
data,
|
|
|
|
currentEpoch,
|
|
|
|
}: {
|
2024-02-20 12:20:35 +00:00
|
|
|
data: EnrichedRewardTransfer[];
|
2024-01-31 14:21:29 +00:00
|
|
|
currentEpoch: number;
|
|
|
|
}) => {
|
|
|
|
const t = useT();
|
2024-03-15 16:41:48 +00:00
|
|
|
const { pubKey } = useVegaWallet();
|
|
|
|
const { team } = useMyTeam();
|
|
|
|
const { stakeAvailable, isEligible, requiredStake } = useStakeAvailable();
|
|
|
|
|
|
|
|
const requirements = pubKey
|
|
|
|
? {
|
|
|
|
isEligible,
|
|
|
|
stakeAvailable,
|
|
|
|
requiredStake,
|
|
|
|
team,
|
|
|
|
pubKey,
|
|
|
|
}
|
|
|
|
: undefined;
|
2024-01-31 14:21:29 +00:00
|
|
|
|
2024-02-15 20:14:04 +00:00
|
|
|
if (!data || data.length === 0) {
|
2024-01-31 14:21:29 +00:00
|
|
|
return (
|
2024-02-20 15:17:02 +00:00
|
|
|
<p className="text-sm">
|
|
|
|
{t('Currently no active games on the network.')}
|
2024-01-31 14:21:29 +00:00
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2024-02-20 15:17:02 +00:00
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
2024-02-15 20:14:04 +00:00
|
|
|
{data.map((game, i) => {
|
2024-01-31 14:21:29 +00:00
|
|
|
// TODO: Remove `kind` prop from ActiveRewardCard
|
|
|
|
const { transfer } = game;
|
|
|
|
if (
|
|
|
|
transfer.kind.__typename !== 'RecurringTransfer' ||
|
|
|
|
!transfer.kind.dispatchStrategy?.dispatchMetric
|
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<ActiveRewardCard
|
|
|
|
key={i}
|
|
|
|
transferNode={game}
|
|
|
|
currentEpoch={currentEpoch}
|
2024-03-15 16:41:48 +00:00
|
|
|
requirements={requirements}
|
2024-01-31 14:21:29 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|