fix(trading): referrals page final commission value and onboarding dialog (#5474)
This commit is contained in:
parent
7c0139e107
commit
2221e9faca
@ -91,8 +91,10 @@ export const ApplyCodeForm = ({ onSuccess }: { onSuccess?: () => void }) => {
|
|||||||
const validateFundsAvailable = useCallback(() => {
|
const validateFundsAvailable = useCallback(() => {
|
||||||
if (requiredFunds && !isEligible) {
|
if (requiredFunds && !isEligible) {
|
||||||
const err = t(
|
const err = t(
|
||||||
'Require minimum of {{requiredFunds}} to join a referral set to protect the network from spam.',
|
'To protect the network from spam, you must have at least {{requiredFunds}} qUSD of any asset on the network to proceed.',
|
||||||
{ replace: { requiredFunds } }
|
{
|
||||||
|
requiredFunds,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ export const useStats = ({
|
|||||||
: 1;
|
: 1;
|
||||||
const finalCommissionValue = isNaN(multiplier)
|
const finalCommissionValue = isNaN(multiplier)
|
||||||
? baseCommissionValue
|
? baseCommissionValue
|
||||||
: multiplier * baseCommissionValue;
|
: new BigNumber(multiplier).times(baseCommissionValue).toNumber();
|
||||||
|
|
||||||
const discountFactorValue = refereeStats?.discountFactor
|
const discountFactorValue = refereeStats?.discountFactor
|
||||||
? Number(refereeStats.discountFactor)
|
? Number(refereeStats.discountFactor)
|
||||||
@ -242,19 +242,23 @@ export const Statistics = ({
|
|||||||
{multiplier || t('None')}
|
{multiplier || t('None')}
|
||||||
</StatTile>
|
</StatTile>
|
||||||
);
|
);
|
||||||
|
const baseCommissionFormatted = BigNumber(baseCommissionValue)
|
||||||
|
.times(100)
|
||||||
|
.toString();
|
||||||
|
const finalCommissionFormatted = new BigNumber(finalCommissionValue)
|
||||||
|
.times(100)
|
||||||
|
.toString();
|
||||||
const finalCommissionTile = (
|
const finalCommissionTile = (
|
||||||
<StatTile
|
<StatTile
|
||||||
title={t('Final commission rate')}
|
title={t('Final commission rate')}
|
||||||
description={
|
description={
|
||||||
!isNaN(multiplier)
|
!isNaN(multiplier)
|
||||||
? `(${baseCommissionValue * 100}% ⨉ ${multiplier} = ${
|
? `(${baseCommissionFormatted}% ⨉ ${multiplier} = ${finalCommissionFormatted}%)`
|
||||||
finalCommissionValue * 100
|
|
||||||
}%)`
|
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
overrideWithNoProgram={!details}
|
overrideWithNoProgram={!details}
|
||||||
>
|
>
|
||||||
{finalCommissionValue * 100}%
|
{finalCommissionFormatted}%
|
||||||
</StatTile>
|
</StatTile>
|
||||||
);
|
);
|
||||||
const numberOfTradersValue = data.referees.length;
|
const numberOfTradersValue = data.referees.length;
|
||||||
|
@ -10,6 +10,7 @@ import { positionsDataProvider } from '@vegaprotocol/positions';
|
|||||||
import { useGlobalStore } from '../../stores';
|
import { useGlobalStore } from '../../stores';
|
||||||
|
|
||||||
const ONBOARDING_STORAGE_KEY = 'vega_onboarding';
|
const ONBOARDING_STORAGE_KEY = 'vega_onboarding';
|
||||||
|
|
||||||
export const useOnboardingStore = create<{
|
export const useOnboardingStore = create<{
|
||||||
dialogOpen: boolean;
|
dialogOpen: boolean;
|
||||||
walletDialogOpen: boolean;
|
walletDialogOpen: boolean;
|
||||||
@ -20,7 +21,7 @@ export const useOnboardingStore = create<{
|
|||||||
}>()(
|
}>()(
|
||||||
persist(
|
persist(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
dialogOpen: true,
|
dialogOpen: false,
|
||||||
walletDialogOpen: false,
|
walletDialogOpen: false,
|
||||||
dismissed: false,
|
dismissed: false,
|
||||||
dismiss: () => set({ dismissed: true }),
|
dismiss: () => set({ dismissed: true }),
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useMatch } from 'react-router-dom';
|
||||||
import { Dialog, Intent } from '@vegaprotocol/ui-toolkit';
|
import { Dialog, Intent } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useEnvironment } from '@vegaprotocol/environment';
|
import { useEnvironment } from '@vegaprotocol/environment';
|
||||||
import { WelcomeDialogContent } from './welcome-dialog-content';
|
|
||||||
import { useOnboardingStore } from './use-get-onboarding-step';
|
|
||||||
import { VegaConnectDialog } from '@vegaprotocol/wallet';
|
import { VegaConnectDialog } from '@vegaprotocol/wallet';
|
||||||
import { Connectors } from '../../lib/vega-connectors';
|
import { Connectors } from '../../lib/vega-connectors';
|
||||||
import { RiskMessage } from './risk-message';
|
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
|
import { Links } from '../../lib/links';
|
||||||
|
import { RiskMessage } from './risk-message';
|
||||||
|
import { WelcomeDialogContent } from './welcome-dialog-content';
|
||||||
|
import { useOnboardingStore } from './use-get-onboarding-step';
|
||||||
|
|
||||||
export const WelcomeDialog = () => {
|
export const WelcomeDialog = () => {
|
||||||
|
const isReferrals = useMatch(Links.REFERRALS());
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const { VEGA_ENV } = useEnvironment();
|
const { VEGA_ENV } = useEnvironment();
|
||||||
const dismissed = useOnboardingStore((store) => store.dismissed);
|
const dismissed = useOnboardingStore((store) => store.dismissed);
|
||||||
const dialogOpen = useOnboardingStore((store) => store.dialogOpen);
|
const dialogOpen = useOnboardingStore((store) => store.dialogOpen);
|
||||||
const dismiss = useOnboardingStore((store) => store.dismiss);
|
const dismiss = useOnboardingStore((store) => store.dismiss);
|
||||||
|
const setDialogOpen = useOnboardingStore((store) => store.setDialogOpen);
|
||||||
const walletDialogOpen = useOnboardingStore(
|
const walletDialogOpen = useOnboardingStore(
|
||||||
(store) => store.walletDialogOpen
|
(store) => store.walletDialogOpen
|
||||||
);
|
);
|
||||||
@ -20,6 +25,12 @@ export const WelcomeDialog = () => {
|
|||||||
(store) => store.setWalletDialogOpen
|
(store) => store.setWalletDialogOpen
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (dismissed) return;
|
||||||
|
if (isReferrals) return;
|
||||||
|
setDialogOpen(true);
|
||||||
|
}, [dismissed, isReferrals, setDialogOpen]);
|
||||||
|
|
||||||
const content = walletDialogOpen ? (
|
const content = walletDialogOpen ? (
|
||||||
<VegaConnectDialog
|
<VegaConnectDialog
|
||||||
connectors={Connectors}
|
connectors={Connectors}
|
||||||
@ -31,7 +42,12 @@ export const WelcomeDialog = () => {
|
|||||||
<WelcomeDialogContent />
|
<WelcomeDialogContent />
|
||||||
);
|
);
|
||||||
|
|
||||||
const onClose = walletDialogOpen ? () => setWalletDialogOpen(false) : dismiss;
|
const onClose = walletDialogOpen
|
||||||
|
? () => setWalletDialogOpen(false)
|
||||||
|
: () => {
|
||||||
|
setDialogOpen(false);
|
||||||
|
dismiss();
|
||||||
|
};
|
||||||
|
|
||||||
const title = walletDialogOpen ? null : (
|
const title = walletDialogOpen ? null : (
|
||||||
<span className="font-alpha calt" data-testid="welcome-title">
|
<span className="font-alpha calt" data-testid="welcome-title">
|
||||||
|
@ -279,6 +279,7 @@
|
|||||||
"This timestamp is user curated metadata and does not drive any on-chain functionality.": "This timestamp is user curated metadata and does not drive any on-chain functionality.",
|
"This timestamp is user curated metadata and does not drive any on-chain functionality.": "This timestamp is user curated metadata and does not drive any on-chain functionality.",
|
||||||
"Tier": "Tier",
|
"Tier": "Tier",
|
||||||
"to": "to",
|
"to": "to",
|
||||||
|
"To protect the network from spam, you must have at least {{requiredFunds}} qUSD of any asset on the network to proceed.": "To protect the network from spam, you must have at least {{requiredFunds}} qUSD of any asset on the network to proceed.",
|
||||||
"Toast location": "Toast location",
|
"Toast location": "Toast location",
|
||||||
"Total discount": "Total discount",
|
"Total discount": "Total discount",
|
||||||
"Total distributed": "Total distributed",
|
"Total distributed": "Total distributed",
|
||||||
|
Loading…
Reference in New Issue
Block a user