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

Cleanup #1412

Merged
merged 3 commits into from
Jan 29, 2025
Merged

Cleanup #1412

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
11 changes: 7 additions & 4 deletions src/components/User/UserRegistration.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { useMutation, ApolloError } from '@apollo/client';
import { useMutation } from '@apollo/client';
import { useForm, FormProvider } from 'react-hook-form';
import { CREATE_USER } from '../../utils/gql/GQL_MUTATIONS';
import { InputField } from '../Input/InputField.component';
Expand All @@ -14,6 +14,11 @@ interface IRegistrationData {
lastName: string;
}

/**
* User registration component that handles WooCommerce customer creation
* @function UserRegistration
* @returns {JSX.Element} - Rendered component with registration form
*/
const UserRegistration = () => {
const methods = useForm<IRegistrationData>();
const [registerUser, { loading, error }] = useMutation(CREATE_USER);
Expand All @@ -27,14 +32,12 @@ const UserRegistration = () => {

const customer = response.data?.registerCustomer?.customer;
if (customer) {
console.log('Customer registration successful:', customer);
setRegistrationCompleted(true);
} else {
throw new Error('Failed to register customer');
}
} catch (err: unknown) {
const error = err as ApolloError;
console.error('Registration error:', error);
console.error('Registration error');
}
};

Expand Down
Loading