From 825856c74d2ba8f32eeb6d4fcde771613776e534 Mon Sep 17 00:00:00 2001 From: Eugene Chybisov Date: Thu, 2 Jan 2025 17:45:59 +0100 Subject: [PATCH] fix: improve step titles in custom steps --- packages/widget/src/components/Step/Step.tsx | 35 +++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/widget/src/components/Step/Step.tsx b/packages/widget/src/components/Step/Step.tsx index 7eca3e193..2df42a2e9 100644 --- a/packages/widget/src/components/Step/Step.tsx +++ b/packages/widget/src/components/Step/Step.tsx @@ -27,36 +27,47 @@ export const Step: React.FC<{ ) const getCardTitle = () => { + const hasBridgeStep = step.includedSteps.some( + (step) => step.type === 'cross' + ) + const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap') + const hasCustomStep = step.includedSteps.some( + (step) => step.type === 'custom' + ) + + const isCustomVariant = hasCustomStep && subvariant === 'custom' + switch (step.type) { case 'lifi': { - const hasBridgeStep = step.includedSteps.some( - (step) => step.type === 'cross' - ) - const hasSwapStep = step.includedSteps.some( - (step) => step.type === 'swap' - ) if (hasBridgeStep && hasSwapStep) { - return subvariant === 'custom' + return isCustomVariant ? subvariantOptions?.custom === 'deposit' ? t('main.stepBridgeAndDeposit') : t('main.stepBridgeAndBuy') : t('main.stepSwapAndBridge') } if (hasBridgeStep) { - return subvariant === 'custom' + return isCustomVariant ? subvariantOptions?.custom === 'deposit' ? t('main.stepBridgeAndDeposit') : t('main.stepBridgeAndBuy') : t('main.stepBridge') } - return subvariant === 'custom' + if (hasSwapStep) { + return isCustomVariant + ? subvariantOptions?.custom === 'deposit' + ? t('main.stepSwapAndDeposit') + : t('main.stepSwapAndBuy') + : t('main.stepSwap') + } + return isCustomVariant ? subvariantOptions?.custom === 'deposit' - ? t('main.stepSwapAndDeposit') - : t('main.stepSwapAndBuy') + ? t('main.stepDeposit') + : t('main.stepBuy') : t('main.stepSwap') } default: - return subvariant === 'custom' + return isCustomVariant ? subvariantOptions?.custom === 'deposit' ? t('main.stepDeposit') : t('main.stepBuy')