HEX
Server: LiteSpeed
System: Linux server902.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: deshuvsd (2181)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/deshuvsd/www/wp-content/plugins/surerank/src/apps/admin-components/schema-utils/utils.js
import { Alert } from '@bsf/force-ui';
import { __ } from '@wordpress/i18n';

export const noFieldsAlert = (
	<Alert
		content={ __(
			'This schema does not have any configurable fields',
			'surerank'
		) }
		className="shadow-none"
		variant="info"
	/>
);

export const generateUUID = ( length = 16 ) => {
	return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
		/[xy]/g,
		function ( c ) {
			const r = Math.floor( Math.random() * length );
			const v = c === 'x' ? r : ( r % 4 ) + 8; // Replace bitwise operations
			return v.toString( 16 );
		}
	);
};

/**
 * Checks if a schema type exists and is valid in schemaTypeData
 * @param {string} schemaTitle - The schema title/name to check
 * @return {boolean} - True if schema exists and has valid data
 */
export const isSchemaTypeValid = ( schemaTitle ) => {
	const schemaTypeData = surerank_globals?.schema_type_data || {};
	return (
		schemaTypeData[ schemaTitle ] &&
		Array.isArray( schemaTypeData[ schemaTitle ] ) &&
		schemaTypeData[ schemaTitle ].length > 0
	);
};