mirror of
				https://gitlab.nic.cz/turris/reforis/foris-js.git
				synced 2025-11-03 23:00:31 +01:00 
			
		
		
		
	Add displayCard function to utils
This commit is contained in:
		
							
								
								
									
										23
									
								
								src/utils/displayCard.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/utils/displayCard.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
 | 
			
		||||
 *
 | 
			
		||||
 * This is free software, licensed under the GNU General Public License v3.
 | 
			
		||||
 * See /LICENSE for more information.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
export function displayCard({ package_lists: packages }, cardName) {
 | 
			
		||||
    const enabledPackagesNames = [];
 | 
			
		||||
    packages
 | 
			
		||||
        .filter((item) => item.enabled)
 | 
			
		||||
        .map((item) => {
 | 
			
		||||
            enabledPackagesNames.push(item.name);
 | 
			
		||||
            item.options
 | 
			
		||||
                .filter((option) => option.enabled)
 | 
			
		||||
                .map((option) => {
 | 
			
		||||
                    enabledPackagesNames.push(option.name);
 | 
			
		||||
                    return null;
 | 
			
		||||
                });
 | 
			
		||||
            return null;
 | 
			
		||||
        });
 | 
			
		||||
    return enabledPackagesNames.includes(cardName);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user