Skip to content

Commit

Permalink
no need to show a step 2 when not applicable (#13818)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed May 9, 2024
1 parent 64779c8 commit 44699ac
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 62 deletions.
1 change: 1 addition & 0 deletions unlock-app/src/components/interface/checkout/Stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const Stepper = ({
hookType,
existingMember,
isRenew,
useDelegatedProvider,
})

const index = items.findIndex(
Expand Down
132 changes: 70 additions & 62 deletions unlock-app/src/components/interface/checkout/main/useStepperItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export function useStepperItems(
hookType,
isRenew,
existingMember: isExistingMember,
useDelegatedProvider,
}: {
isRenew?: boolean
isUnlockAccount?: boolean
hookType?: CheckoutHookType
existingMember?: boolean
useDelegatedProvider?: boolean
} = {}
) {
const {
Expand Down Expand Up @@ -60,70 +62,76 @@ export function useStepperItems(
name: 'Select',
to: 'SELECT',
},
{
]
if (!useDelegatedProvider) {
checkoutItems.push({
name: 'Connect',
to: isUnlockAccount ? 'UNLOCK_ACCOUNT' : 'CONNECT',
},
{
name: 'Choose quantity',
skip: (!hasOneLock ? skipQuantity : skipLockQuantity) || isExpired,
to: 'QUANTITY',
},
{
name: 'Recipient(s)',
to: 'METADATA',
skip:
(!hasOneLock
? skipRecipient && skipQuantity && !isMember
: skipLockQuantity && skipLockRecipient && !isMember) || isExpired,
},
{
name: 'Sign message',
skip: !paywallConfig.messageToSign,
to: 'MESSAGE_TO_SIGN',
},
isPassword
? {
name: 'Submit password',
to: 'PASSWORD',
}
: isPromo
? {
name: 'Enter promo code',
to: 'PROMO',
}
: isGuild
? {
name: 'Guild',
to: 'GUILD',
}
: isGitcoin
? {
name: 'Gitcoin Passport Verification',
to: 'GITCOIN',
}
: {
name: 'Solve captcha',
to: 'CAPTCHA',
skip: !isCaptcha,
},
{
name: 'Payment method',
to: 'PAYMENT',
},
{
name: 'Add card',
to: 'CARD',
skip: !['card'].includes(payment?.method),
},
{
name: 'Confirm',
to: 'CONFIRM',
},
{
name: 'Minting NFT',
},
]
})
}
checkoutItems.push(
...[
{
name: 'Choose quantity',
skip: (!hasOneLock ? skipQuantity : skipLockQuantity) || isExpired,
to: 'QUANTITY',
},
{
name: 'Recipient(s)',
to: 'METADATA',
skip:
(!hasOneLock
? skipRecipient && skipQuantity && !isMember
: skipLockQuantity && skipLockRecipient && !isMember) || isExpired,
},
{
name: 'Sign message',
skip: !paywallConfig.messageToSign,
to: 'MESSAGE_TO_SIGN',
},
isPassword
? {
name: 'Submit password',
to: 'PASSWORD',
}
: isPromo
? {
name: 'Enter promo code',
to: 'PROMO',
}
: isGuild
? {
name: 'Guild',
to: 'GUILD',
}
: isGitcoin
? {
name: 'Gitcoin Passport Verification',
to: 'GITCOIN',
}
: {
name: 'Solve captcha',
to: 'CAPTCHA',
skip: !isCaptcha,
},
{
name: 'Payment method',
to: 'PAYMENT',
},
{
name: 'Add card',
to: 'CARD',
skip: !['card'].includes(payment?.method),
},
{
name: 'Confirm',
to: 'CONFIRM',
},
{
name: 'Minting NFT',
},
]
)

return checkoutItems
}

0 comments on commit 44699ac

Please sign in to comment.