import {useShopActionQuery} from '../../internal/reactQuery' import {useShopActions} from '../../internal/useShopActions' import { DataHookOptionsBase, DataHookReturnsBase, UserProfile, } from '../../types' export interface UseCurrentUserParams extends DataHookOptionsBase {} export interface UseCurrentUserReturns extends DataHookReturnsBase { /** * The current user logged into Shop. */ currentUser: UserProfile | null } /** * Hook to fetch the current user's profile. */ export const useCurrentUser = ( params?: UseCurrentUserParams ): UseCurrentUserReturns => { const {skip, ...shopActionParams} = params || {} const {getCurrentUser} = useShopActions() const {data, ...rest} = useShopActionQuery( ['currentUser', shopActionParams], getCurrentUser, shopActionParams, {skip} ) return { ...rest, currentUser: data, } } /** * The `useCurrentUser` hook fetches the Shop app user's profile information including display name and avatar image URL. Use this for personalizing the UI, displaying user info in headers/profiles, or conditionally showing features based on authentication status. * * * > Caution: This hook requires adding the following scopes to the manifest file: * > * > `user_settings:read` * > * > For more details, see [manifest.json](/docs/api/shop-minis/manifest-file). * * @publicDocs */ export type UseCurrentUserGeneratedType = ( params?: UseCurrentUserParams ) => UseCurrentUserReturns