// Enhanced composable for getting user data from Magento (global vars + URL fallback)
export function useUserId(paramName = 'userId') {
    const params = new URLSearchParams(window.location.search);
    return params.get(paramName);
}

// New composable for getting all Magento user data
export function useMagentoUser() {
    // Primary: Get from global variable set by Magento PHP
    if (window.magentoUserData) {
        return {
            userId: window.magentoUserData.userId,
            email: window.magentoUserData.email,
            phone: window.magentoUserData.phone,
            source: 'global'
        };
    }

    // Fallback: Get from URL parameters
    const params = new URLSearchParams(window.location.search);
    const userId = params.get('userId');
    const email = params.get('email');
    const phone = params.get('phone');

    if (userId) {
        return {
            userId,
            email,
            phone,
            source: 'url'
        };
    }

    // No data found
    return {
        userId: null,
        email: null,
        phone: null,
        source: null
    };
}