Skip to main content

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

ParameterTypeDescription
attributesObjectBlock attributes passed to the component.
onActionFunctionAction handler for navigation and messages.
coreDispatchFunctionCore dispatch function for updating app state.
defaultValuesObjectOptional default values for the form fields.

Return Value

PropertyTypeDescription
userObjectThe current user object from app storage.
firstNamestringUser's first name.
lastNamestringUser's last name.
emailstringUser's email address.
phonestringUser's phone number.
updateProfileFunctionSubmits the profile update form to Shopify.
isLoadingbooleanWhether the profile update is in progress.
controlObjectreact-hook-form control object for form inputs.
handleSubmitFunctionreact-hook-form submit handler.
formStateObjectreact-hook-form form state (errors, dirty fields, etc.).
setErrorFunctionreact-hook-form function to manually set field errors.
setFocusFunctionreact-hook-form function to programmatically focus a field.