-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: #82/checkout middleware #89
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some improvements, but LGTM
switch (currentPath) { | ||
case 'shipping': | ||
if (!canEnterShipping(activeCart)) { | ||
app.context.redirect('/'); | ||
} | ||
break; | ||
case 'billing': | ||
if (!canEnterBilling(activeCart)) { | ||
app.context.redirect('/'); | ||
} | ||
break; | ||
case 'payment': | ||
if (!canEnterPayment(activeCart)) { | ||
app.context.redirect('/'); | ||
} | ||
break; | ||
case 'thank-you': | ||
if (!canEnterThankYou(app.context)) { | ||
app.context.redirect('/'); | ||
} | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better option is to have just if.
switch (currentPath) { | |
case 'shipping': | |
if (!canEnterShipping(activeCart)) { | |
app.context.redirect('/'); | |
} | |
break; | |
case 'billing': | |
if (!canEnterBilling(activeCart)) { | |
app.context.redirect('/'); | |
} | |
break; | |
case 'payment': | |
if (!canEnterPayment(activeCart)) { | |
app.context.redirect('/'); | |
} | |
break; | |
case 'thank-you': | |
if (!canEnterThankYou(app.context)) { | |
app.context.redirect('/'); | |
} | |
break; | |
} | |
if(currentPath === 'shipping' && !canEnterShipping(activeCart)) { | |
app.context.redirect('/'); | |
return; | |
} | |
if(currentPath === 'billing' && !canEnterBilling(activeCart)) { | |
app.context.redirect('/'); | |
return; | |
} | |
if(currentPath === 'payment' && !canEnterPayment(activeCart)) { | |
app.context.redirect('/'); | |
return; | |
} | |
if(currentPath === 'thank-you' && !canEnterThankYou(app.context)) { | |
app.context.redirect('/'); | |
return; | |
} | |
} |
Also IMO good idea is to replace strings via const or enum values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const or enum values sound cool for me too
@@ -140,6 +142,18 @@ export default { | |||
isFormSubmitted.value = true; | |||
}; | |||
|
|||
onMounted(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe its better to load that onSSR, this will verify quicker if user has access to this page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to put it in onSSRc lifecycle hook at first but it did not work. Now when you have already filled the customer step data and you are in other step (like shipping) when you come back to customer the data will be filled for you.
Description
Closes #82
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: