useUserProfileV2
This hook provides user profile management with form validation using react-hook-form and Zod schema. It allows reading and updating the current user's profile (first name, last name, email, phone).
Import
import { useUserProfileV2 } from '@appmaker-xyz/shopify';
Basic Usage
const {
user,
firstName,
lastName,
email,
phone,
control,
handleSubmit,
formState,
updateProfile,
isLoading,
} = useUserProfileV2({ attributes, onAction, coreDispatch });
Parameters
| Parameter | Type | Description |
|---|---|---|
attributes | Object | Block attributes passed to the component. |
onAction | Function | Action handler for navigation and messages. |
coreDispatch | Function | Core dispatch function for updating app state. |
defaultValues | Object | Optional default values for the form fields. |
Return Value
| Property | Type | Description |
|---|---|---|
user | Object | The current user object from app storage. |
firstName | string | User's first name. |
lastName | string | User's last name. |
email | string | User's email address. |
phone | string | User's phone number. |
updateProfile | Function | Submits the profile update form to Shopify. |
isLoading | boolean | Whether the profile update is in progress. |
control | Object | react-hook-form control object for form inputs. |
handleSubmit | Function | react-hook-form submit handler. |
formState | Object | react-hook-form form state (errors, dirty fields, etc.). |
setError | Function | react-hook-form function to manually set field errors. |
setFocus | Function | react-hook-form function to programmatically focus a field. |