Skip to content

Commit 64aaeb9

Browse files
authored
refactor(app): do not show progress indication during drop tip wizard (#16954)
Closes RQA-3643 Because drop tip flows is no longer deterministic, we shouldn't show the progress bar and step counter.
1 parent 8b2196a commit 64aaeb9

File tree

2 files changed

+2
-84
lines changed

2 files changed

+2
-84
lines changed

app/src/organisms/DropTipWizardFlows/DropTipWizardHeader.tsx

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { useState, useEffect } from 'react'
21
import { useTranslation } from 'react-i18next'
32

4-
import { BEFORE_BEGINNING, BLOWOUT_SUCCESS, DT_ROUTES } from './constants'
53
import { WizardHeader } from '/app/molecules/WizardHeader'
64

75
import type { DropTipWizardProps } from './DropTipWizard'
8-
import type { DropTipFlowsRoute, DropTipFlowsStep, ErrorDetails } from './types'
6+
import type { ErrorDetails } from './types'
97

108
type DropTipWizardHeaderProps = DropTipWizardProps & {
119
isExitInitiated: boolean
@@ -16,9 +14,6 @@ type DropTipWizardHeaderProps = DropTipWizardProps & {
1614

1715
export function DropTipWizardHeader({
1816
confirmExit,
19-
currentStep,
20-
currentRoute,
21-
currentStepIdx,
2217
isExitInitiated,
2318
isFinalWizardStep,
2419
errorDetails,
@@ -36,73 +31,14 @@ export function DropTipWizardHeader({
3631
handleCleanUpAndClose,
3732
})
3833

39-
const { totalSteps, currentStepNumber } = useSeenBlowoutSuccess({
40-
currentStep,
41-
currentRoute,
42-
currentStepIdx,
43-
})
44-
4534
return (
4635
<WizardHeader
4736
title={i18n.format(t('drop_tips'), 'capitalize')}
48-
currentStep={currentStepNumber}
49-
totalSteps={totalSteps}
5037
onExit={!showConfirmExit ? wizardHeaderOnExit : null}
5138
/>
5239
)
5340
}
5441

55-
interface UseSeenBlowoutSuccessProps {
56-
currentStep: DropTipFlowsStep
57-
currentRoute: DropTipFlowsRoute
58-
currentStepIdx: number
59-
}
60-
61-
interface UseSeenBlowoutSuccessResult {
62-
currentStepNumber: number | null
63-
totalSteps: number | null
64-
}
65-
66-
// Calculate the props used for determining step count based on the route. Because blowout and drop tip are separate routes,
67-
// there's a need for state to track whether we've seen blowout, so the step counter is accurate when the drop tip route is active.
68-
export function useSeenBlowoutSuccess({
69-
currentStep,
70-
currentRoute,
71-
currentStepIdx,
72-
}: UseSeenBlowoutSuccessProps): UseSeenBlowoutSuccessResult {
73-
const [hasSeenBlowoutSuccess, setHasSeenBlowoutSuccess] = useState(false)
74-
75-
useEffect(() => {
76-
if (currentStep === BLOWOUT_SUCCESS) {
77-
setHasSeenBlowoutSuccess(true)
78-
} else if (currentStep === BEFORE_BEGINNING) {
79-
setHasSeenBlowoutSuccess(false)
80-
}
81-
}, [currentStep])
82-
83-
const shouldRenderStepCounter = currentRoute !== DT_ROUTES.BEFORE_BEGINNING
84-
85-
let totalSteps: null | number
86-
if (!shouldRenderStepCounter) {
87-
totalSteps = null
88-
} else if (currentRoute === DT_ROUTES.BLOWOUT || hasSeenBlowoutSuccess) {
89-
totalSteps = DT_ROUTES.BLOWOUT.length + DT_ROUTES.DROP_TIP.length
90-
} else {
91-
totalSteps = currentRoute.length
92-
}
93-
94-
let currentStepNumber: null | number
95-
if (!shouldRenderStepCounter) {
96-
currentStepNumber = null
97-
} else if (hasSeenBlowoutSuccess && currentRoute === DT_ROUTES.DROP_TIP) {
98-
currentStepNumber = DT_ROUTES.BLOWOUT.length + currentStepIdx + 1
99-
} else {
100-
currentStepNumber = currentStepIdx + 1
101-
}
102-
103-
return { currentStepNumber, totalSteps }
104-
}
105-
10642
export interface UseWizardExitHeaderProps {
10743
isFinalStep: boolean
10844
hasInitiatedExit: boolean

app/src/organisms/DropTipWizardFlows/__tests__/DropTipWizardHeader.test.tsx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import type * as React from 'react'
22
import { beforeEach, describe, expect, it, vi } from 'vitest'
3-
import { renderHook, screen } from '@testing-library/react'
3+
import { screen } from '@testing-library/react'
44

55
import { renderWithProviders } from '/app/__testing-utils__'
66
import { i18n } from '/app/i18n'
77
import { mockDropTipWizardContainerProps } from '../__fixtures__'
88
import {
99
useWizardExitHeader,
10-
useSeenBlowoutSuccess,
1110
DropTipWizardHeader,
1211
} from '../DropTipWizardHeader'
13-
import { DT_ROUTES } from '../constants'
1412

1513
import type { Mock } from 'vitest'
1614
import type { UseWizardExitHeaderProps } from '../DropTipWizardHeader'
@@ -31,22 +29,6 @@ describe('DropTipWizardHeader', () => {
3129
it('renders appropriate copy and onClick behavior', () => {
3230
render(props)
3331
screen.getByText('Drop tips')
34-
screen.getByText('Step 1 / 5')
35-
})
36-
})
37-
38-
describe('useSeenBlowoutSuccess', () => {
39-
it('should not render step counter when currentRoute is BEFORE_BEGINNING', () => {
40-
const { result } = renderHook(() =>
41-
useSeenBlowoutSuccess({
42-
currentStep: 'SOME_STEP' as any,
43-
currentRoute: DT_ROUTES.BEFORE_BEGINNING,
44-
currentStepIdx: 0,
45-
})
46-
)
47-
48-
expect(result.current.totalSteps).toBe(null)
49-
expect(result.current.currentStepNumber).toBe(null)
5032
})
5133
})
5234

0 commit comments

Comments
 (0)