File tree Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 6767 required
6868 class =" form__element"
6969 style =" margin-top : 10px "
70- @keypress.enter =" handleSubmit(submitForm(reset))"
7170 />
7271 <SfButton
7372 class =" form__button"
74- @click =" handleSubmit(submitForm(reset))"
7573 >
7674 {{ $t('Update personal data') }}
7775 </SfButton >
9189 required
9290 class =" form__element"
9391 style =" margin-top : 10px "
94- @keypress.enter =" handleSubmit(submitForm(reset))"
9592 />
9693 <SfButton
9794 class =" form__button"
98- @click =" handleSubmit(submitForm(reset))"
9995 >
10096 {{ $t('Update personal data') }}
10197 </SfButton >
114110import { defineComponent , ref } from ' @nuxtjs/composition-api' ;
115111import { ValidationProvider , ValidationObserver , extend } from ' vee-validate' ;
116112import { email } from ' vee-validate/dist/rules' ;
117- import { userGetters } from ' ~/getters' ;
118113import { SfInput , SfButton , SfModal } from ' @storefront-ui/vue' ;
114+ import { userGetters } from ' ~/getters' ;
119115import { useUiNotification , useUser } from ' ~/composables' ;
120116
121117extend (' email' , {
@@ -169,10 +165,15 @@ export default defineComponent({
169165 resetValidationFn ();
170166 };
171167
172- const onError = () => {
173- form .value = resetForm ();
174- requirePassword .value = false ;
175- currentPassword .value = ' ' ;
168+ const onError = (msg ) => {
169+ sendNotification ({
170+ id: Symbol (' user_updated' ),
171+ message: msg,
172+ type: ' danger' ,
173+ icon: ' cross' ,
174+ persist: false ,
175+ title: ' User Account' ,
176+ });
176177 };
177178
178179 if (
Original file line number Diff line number Diff line change @@ -32,6 +32,14 @@ export const useUser = (): UseUser => {
3232 error . value = errorsFactory ( ) ;
3333 } ;
3434
35+ const updateCustomerEmail = async ( credentials : { email : string , password : string } ) : Promise < void > => {
36+ const { errors } = await app . context . $vsf . $magento . api . updateCustomerEmail ( credentials ) ;
37+
38+ if ( errors ) {
39+ throw errors . map ( ( e ) => e . message ) . join ( ',' ) ;
40+ }
41+ } ;
42+
3543 // eslint-disable-next-line consistent-return
3644 const updateUser = async ( { user : providedUser , customQuery } ) => {
3745 Logger . debug ( '[Magento] Update user information' , { providedUser, customQuery } ) ;
@@ -45,7 +53,7 @@ export const useUser = (): UseUser => {
4553 const userData = generateUserData ( updateData ) ;
4654
4755 if ( email && email !== oldEmail ) {
48- await app . context . $vsf . $magento . api . updateCustomerEmail ( {
56+ await updateCustomerEmail ( {
4957 email,
5058 password,
5159 } ) ;
@@ -57,6 +65,7 @@ export const useUser = (): UseUser => {
5765 if ( errors ) {
5866 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
5967 Logger . error ( errors . map ( ( e ) => e . message ) . join ( ',' ) ) ;
68+ error . value . updateUser = errors . map ( ( e ) => e . message ) . join ( ',' ) ;
6069 }
6170
6271 customerStore . user = data ?. updateCustomerV2 ?. customer || { } ;
Original file line number Diff line number Diff line change @@ -36,8 +36,7 @@ import {
3636 confirmed ,
3737} from ' vee-validate/dist/rules' ;
3838import { SfTabs } from ' @storefront-ui/vue' ;
39- import { onSSR } from ' @vue-storefront/core' ;
40- import { defineComponent } from ' @nuxtjs/composition-api' ;
39+ import { defineComponent , useFetch } from ' @nuxtjs/composition-api' ;
4140import { useUser } from ' ~/composables' ;
4241import ProfileUpdateForm from ' ~/components/MyAccount/ProfileUpdateForm.vue' ;
4342import PasswordResetForm from ' ~/components/MyAccount/PasswordResetForm.vue' ;
@@ -112,7 +111,7 @@ export default defineComponent({
112111 new: form .value .newPassword ,
113112 }), onComplete, onError);
114113
115- onSSR (async () => {
114+ useFetch (async () => {
116115 await load ();
117116 });
118117
You can’t perform that action at this time.
0 commit comments