Skip to content

Commit d113c5e

Browse files
giacomosardoalessani
authored andcommitted
fix: step flow
1 parent 337dd7e commit d113c5e

3 files changed

Lines changed: 26 additions & 31 deletions

File tree

components/composite/StepNav/Step.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ interface StepProps {
88

99
export const Step = styled.li<StepProps>`
1010
position: relative;
11-
${tw`flex items-center last:pointer-events-none`}
11+
${tw`flex items-center`}
1212
1313
${({ isActive }) =>
1414
isActive
1515
? css`
1616
${tw`font-bold text-black`}
1717
`
1818
: null}
19-
${({ isLocked }) =>
20-
isLocked
19+
${({ isLocked, isActive }) =>
20+
isLocked && !isActive
2121
? css`
2222
${tw`text-gray-400 pointer-events-none`}
2323
`

components/composite/StepNav/index.tsx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export const StepNav: React.FC<Props> = ({
3232
const isLocked =
3333
(step === "Shipping" && !ctx?.isShipmentRequired) ||
3434
(step === "Payment" && !ctx?.isPaymentRequired) ||
35-
(steps.indexOf(step) > steps.indexOf(lastActivable) &&
36-
lastActivable !== "Complete")
35+
steps.indexOf(step) > steps.indexOf(lastActivable)
3736

3837
return (
3938
<Step
@@ -49,28 +48,23 @@ export const StepNav: React.FC<Props> = ({
4948
isLocked={isLocked}
5049
>
5150
{t(`step${step}.title`)}
52-
<svg
53-
xmlns="http://www.w3.org/2000/svg"
54-
className="w-3 h-3 mx-3 fill-current"
55-
viewBox="0 0 20 20"
56-
fill="currentColor"
57-
>
58-
<path
59-
fillRule="evenodd"
60-
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
61-
clipRule="evenodd"
62-
/>
63-
</svg>
51+
{step !== "Payment" && (
52+
<svg
53+
xmlns="http://www.w3.org/2000/svg"
54+
className="w-3 h-3 mx-3 fill-current"
55+
viewBox="0 0 20 20"
56+
fill="currentColor"
57+
>
58+
<path
59+
fillRule="evenodd"
60+
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
61+
clipRule="evenodd"
62+
/>
63+
</svg>
64+
)}
6465
</Step>
6566
)
6667
})}
67-
68-
<Step
69-
isLocked={activeStep !== "Complete"}
70-
isActive={activeStep === "Complete"}
71-
>
72-
{t("general.complete")}
73-
</Step>
7468
</StepList>
7569
</Wrapper>
7670
)

components/ui/Accordion/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export const AccordionItem: React.FC<Props> = ({ children, index, header }) => {
2424
if (!ctx || !appCtx) return null
2525

2626
const handleSelection = () => {
27-
if (ctx.status !== "disabled") {
27+
if (
28+
(ctx.step === "Shipping" && appCtx.hasPaymentMethod) ||
29+
ctx.status !== "disabled"
30+
) {
2831
return ctx.isActive ? ctx.closeStep() : ctx.setStep()
2932
}
3033
}
@@ -34,8 +37,10 @@ export const AccordionItem: React.FC<Props> = ({ children, index, header }) => {
3437
tabIndex={index}
3538
className={classNames("group", {
3639
active: ctx.isActive,
37-
disabled: ctx.status === "disabled",
38-
cannotGoNext: ctx.cannotGoNext,
40+
disabled: !(
41+
(ctx.step === "Shipping" && appCtx.hasPaymentMethod) ||
42+
ctx.status !== "disabled"
43+
),
3944
})}
4045
>
4146
<AccordionTabHeader className="group" onClick={handleSelection}>
@@ -75,10 +80,6 @@ const AccordionTabHeader = styled.div`
7580
.disabled & {
7681
${tw`pointer-events-none`}
7782
}
78-
79-
.cannotGoNext & {
80-
${tw`pointer-events-none`}
81-
}
8283
`
8384
const AccordionTitle = styled.div`
8485
${tw`transition ease duration-500`}

0 commit comments

Comments
 (0)