import { getDateTimeFormat } from '@vegaprotocol/utils';
import { useReferralProgram } from './hooks/use-referral-program';
import { Table } from './table';
import classNames from 'classnames';
import { BORDER_COLOR, GRADIENT } from './constants';
import { Tag } from './tag';
import type { ComponentProps, ReactNode } from 'react';
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { DApp, TOKEN_PROPOSALS, useLinks } from '@vegaprotocol/environment';
import { useT, ns } from '../../lib/use-t';
import { Trans } from 'react-i18next';
const Loading = ({ variant }: { variant: 'large' | 'inline' }) => (
);
const StakingTier = ({
tier,
label,
referralRewardMultiplier,
minimumStakedTokens,
}: {
tier: number;
label: string;
referralRewardMultiplier: string;
minimumStakedTokens: string;
}) => {
const t = useT();
const color: Record['color']> = {
1: 'green',
2: 'blue',
3: 'pink',
};
return (
{tier < 4 && (
// eslint-disable-next-line @next/next/no-img-element
)}
Multiplier {referralRewardMultiplier}x
{label}
{t('Stake a minimum of {{minimumStakedTokens}} $VEGA tokens', {
minimumStakedTokens,
})}
);
};
export const TiersContainer = () => {
const t = useT();
const { benefitTiers, stakingTiers, details, loading, error } =
useReferralProgram();
const ends = details?.endOfProgramTimestamp
? getDateTimeFormat().format(new Date(details.endOfProgramTimestamp))
: undefined;
const governanceLink = useLinks(DApp.Governance);
if ((!loading && !details) || error) {
return (
{t('here')}
,
]}
ns={ns}
/>
);
}
return (
<>
{/* Benefit tiers */}
{t('Referral tiers')}
{ends && (
{t('Program ends:')} {ends}
)}
{loading || !benefitTiers || benefitTiers.length === 0 ? (
) : (
({
...bt,
tierElement: (
{bt.tier}
),
}))}
/>
)}
{/* Staking tiers */}
{t('Staking multipliers')}
{loading || !stakingTiers || stakingTiers.length === 0 ? (
<>
>
) : (
)}
>
);
};
const StakingTiers = ({
data,
}: {
data: ReturnType['stakingTiers'];
}) => (
<>
{data.map(
({ tier, label, referralRewardMultiplier, minimumStakedTokens }, i) => (
)
)}
>
);
const TiersTable = ({
data,
windowLength,
}: {
data: Array<{
tier: number;
tierElement: ReactNode;
commission: string;
discount: string;
volume: string;
}>;
windowLength?: number;
}) => {
const t = useT();
return (
({
...d,
className: classNames({
'from-vega-pink-400 dark:from-vega-pink-600 to-20% bg-highlight':
d.tier === 1,
'from-vega-purple-400 dark:from-vega-purple-600 to-20% bg-highlight':
d.tier === 2,
'from-vega-blue-400 dark:from-vega-blue-600 to-20% bg-highlight':
d.tier === 3,
'from-vega-orange-400 dark:from-vega-orange-600 to-20% bg-highlight':
d.tier > 3,
}),
}))}
/>
);
};