@@ -10,7 +10,8 @@ import { Logger } from '~/helpers/logger';
1010import { useCustomerStore } from '~/modules/customer/stores/customer' ;
1111import { useCart } from '~/modules/checkout/composables/useCart' ;
1212import { generateUserData } from '~/modules/customer/helpers/generateUserData' ;
13- import { Customer } from '~/modules/GraphQL/types' ;
13+ import { useUiNotification } from '~/composables/useUiNotification' ;
14+ import type { Customer } from '~/modules/GraphQL/types' ;
1415import type {
1516 UseUserInterface ,
1617 UseUserErrors ,
@@ -31,6 +32,7 @@ export function useUser(): UseUserInterface {
3132 const customerStore = useCustomerStore ( ) ;
3233 const { app } = useContext ( ) ;
3334 const { setCart } = useCart ( ) ;
35+ const { send : sendNotification } = useUiNotification ( ) ;
3436 const loading : Ref < boolean > = ref ( false ) ;
3537 const errorsFactory = ( ) : UseUserErrors => ( {
3638 updateUser : null ,
@@ -240,12 +242,16 @@ export function useUser(): UseUserInterface {
240242
241243 Logger . debug ( '[Result]:' , { data } ) ;
242244
243- if ( errors ) {
245+ if ( errors || ! data || ! data . createCustomerV2 || ! data . createCustomerV2 . customer ) {
244246 Logger . error ( errors . map ( ( e ) => e . message ) . join ( ',' ) ) ;
245- }
246-
247- if ( ! data || ! data . createCustomerV2 || ! data . createCustomerV2 . customer ) {
248- Logger . error ( 'Customer registration error' ) ; // todo: handle errors in better way
247+ errors . map ( ( registerError , i ) => sendNotification ( {
248+ icon : 'error' ,
249+ id : Symbol ( `registration_error-${ i } ` ) ,
250+ message : registerError . message ,
251+ persist : true ,
252+ title : 'Registration error' ,
253+ type : 'danger' ,
254+ } ) ) ;
249255 }
250256
251257 // if (recaptchaToken) { // todo: move recaptcha to separate module
0 commit comments