Skip to content

Commit 516bb31

Browse files
committed
feat: add prop isActive to StepPlaceOrder
1 parent e84445e commit 516bb31

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

components/composite/Checkout/index.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,13 @@ const Checkout: React.FC<Props> = ({
144144
>
145145
<StepPayment tw="mb-6" />
146146
</AccordionItem>
147-
<AccordionProvider
148-
activeStep={activeStep}
149-
lastActivableStep={lastActivableStep}
150-
setActiveStep={setActiveStep}
151-
step="Complete"
152-
>
153-
<StepPlaceOrder
154-
termsUrl={termsUrl}
155-
privacyUrl={privacyUrl}
156-
/>
157-
</AccordionProvider>
147+
<StepPlaceOrder
148+
isActive={
149+
activeStep === "Payment" || activeStep === "Complete"
150+
}
151+
termsUrl={termsUrl}
152+
privacyUrl={privacyUrl}
153+
/>
158154
</PaymentContainer>
159155
</AccordionProvider>
160156
</Accordion>

components/composite/StepPlaceOrder/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useRouter } from "next/router"
44
import { useContext, useState } from "react"
55
import { Trans, useTranslation } from "react-i18next"
66

7-
import { AccordionContext } from "components/data/AccordionProvider"
87
import { AppContext } from "components/data/AppProvider"
98
import { GTMContext } from "components/data/GTMProvider"
109
import { ButtonWrapper } from "components/ui/Button"
@@ -25,18 +24,22 @@ import {
2524
} from "./styled"
2625

2726
interface Props {
27+
isActive: boolean
2828
termsUrl: string
2929
privacyUrl: string
3030
}
3131

32-
const StepPlaceOrder: React.FC<Props> = ({ termsUrl, privacyUrl }) => {
32+
const StepPlaceOrder: React.FC<Props> = ({
33+
isActive,
34+
termsUrl,
35+
privacyUrl,
36+
}) => {
3337
const { t } = useTranslation()
3438
const { query } = useRouter()
3539

3640
const [isPlacingOrder, setIsPlacingOrder] = useState(false)
3741

3842
const appCtx = useContext(AppContext)
39-
const accordionCtx = useContext(AccordionContext)
4043
const gtmCtx = useContext(GTMContext)
4144

4245
if (!appCtx) {
@@ -146,7 +149,7 @@ const StepPlaceOrder: React.FC<Props> = ({ termsUrl, privacyUrl }) => {
146149
<ButtonWrapper>
147150
<StyledPlaceOrderButton
148151
data-cy="place-order-button"
149-
isActive={accordionCtx?.isActive}
152+
isActive={isActive}
150153
onClick={handlePlaceOrder}
151154
label={
152155
<>

0 commit comments

Comments
 (0)