Skip to content
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

fix(checkout): login and register in checkout should show errors #1163

Merged
merged 4 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions packages/theme/modules/checkout/pages/Checkout/UserAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default defineComponent({
const loading = computed(() => loadingUser.value || loadingGuestUser.value);

const canMoveForward = computed(() => !(loading.value));
const hasError = computed(() => errorUser.value.register || errorGuestUser.value.attachToCart);
const anyError = computed(() => errorUser.value.login || errorUser.value.register || errorGuestUser.value.attachToCart);

type Form = {
firstname: string,
Expand Down Expand Up @@ -249,9 +249,9 @@ export default defineComponent({
}

await (
!createUserAccount.value
? attachToCart({ email: form.value.email, cart })
: register({ user: form.value })
createUserAccount.value
? register({ user: form.value })
: attachToCart({ email: form.value.email, cart })
);
}

Expand All @@ -270,24 +270,23 @@ export default defineComponent({
});
}

if (!hasError.value) {
await mergeItem('checkout', { 'user-account': form.value });
await router.push(`${app.localePath('/checkout/shipping')}`);
reset();
isFormSubmitted.value = true;
} else {
if (anyError.value) {
sendNotification({
id: Symbol('user_form_error'),
message: 'Something went wrong during form submission. Please try again later',
message: app.i18n.t(anyError.value.message) as string,
type: 'danger',
icon: 'error',
persist: false,
title: 'Error',
});
} else {
await mergeItem('checkout', { 'user-account': form.value });
await router.push(app.localeRoute({ name: 'shipping' }));
reset();
isFormSubmitted.value = true;
}

if (isRecaptchaEnabled.value) {
// reset recaptcha
$recaptcha.reset();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export function useUser(): UseUserInterface {
title: 'Registration error',
type: 'danger',
}));
return;
}

// if (recaptchaToken) { // todo: move recaptcha to separate module
Expand Down