1
1
import { useState } from 'react' ;
2
- import { useMutation , ApolloError } from '@apollo/client' ;
2
+ import { useMutation } from '@apollo/client' ;
3
3
import { useForm , FormProvider } from 'react-hook-form' ;
4
4
import { CREATE_USER } from '../../utils/gql/GQL_MUTATIONS' ;
5
5
import { InputField } from '../Input/InputField.component' ;
@@ -14,6 +14,11 @@ interface IRegistrationData {
14
14
lastName : string ;
15
15
}
16
16
17
+ /**
18
+ * User registration component that handles WooCommerce customer creation
19
+ * @function UserRegistration
20
+ * @returns {JSX.Element } - Rendered component with registration form
21
+ */
17
22
const UserRegistration = ( ) => {
18
23
const methods = useForm < IRegistrationData > ( ) ;
19
24
const [ registerUser , { loading, error } ] = useMutation ( CREATE_USER ) ;
@@ -27,14 +32,12 @@ const UserRegistration = () => {
27
32
28
33
const customer = response . data ?. registerCustomer ?. customer ;
29
34
if ( customer ) {
30
- console . log ( 'Customer registration successful:' , customer ) ;
31
35
setRegistrationCompleted ( true ) ;
32
36
} else {
33
37
throw new Error ( 'Failed to register customer' ) ;
34
38
}
35
39
} catch ( err : unknown ) {
36
- const error = err as ApolloError ;
37
- console . error ( 'Registration error:' , error ) ;
40
+ console . error ( 'Registration error' ) ;
38
41
}
39
42
} ;
40
43
0 commit comments