appice.controller('appDashboardController',
	function ($scope,appIceService) {
        var userType = 'I';
        $scope.val = 'all';
    function init(){
        checkAppid();
    }

    // If someone tries to access app dashboard directly,this function will handle tht
    const checkAppid = function(){
        function extractAppId(url) {
            const regex = /[?&]app_id=([^&]+)/;
            const match = regex.exec(url);
            if (match) {
                return match[1]; // Return the value captured by the regex
            } else {
                return null; // Return null if app_id parameter is not found
            }
        }
        // Get the current URL
        const currentUrl = window.location.href;
     
        // get the  appid from the url 
        const appId = extractAppId(currentUrl);

        // if user doesn't have been approved for this app 
        if (!(appId && semusiCommon.getActiveUser && semusiCommon.getActiveUser.approved_appids.includes(appId))) {
            window.location =  "/dashboard";                // redirect to the dashboard page 
            showError("Your approval is pending for this App. Please contact the Admin.")       // Show the error message
        }
    }
      
    window.onload = init;
});
