HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/bwcsports-site/wp-content/plugins/quiz-master-next/blocks/src/page/edit.js
import { __ } from '@wordpress/i18n';
import { useState, useEffect } from '@wordpress/element';
import apiFetch from '@wordpress/api-fetch';
import {
	InspectorControls,
	InnerBlocks,
	useBlockProps,
} from '@wordpress/block-editor';
import {
	PanelBody,
	PanelRow,
	TextControl,
	ToggleControl,
	RangeControl,
	RadioControl,
	SelectControl,
} from '@wordpress/components';
import { qsmIsEmpty } from '../helper';
export default function Edit( props ) {
	//check for QSM initialize data
	if ( 'undefined' === typeof qsmBlockData ) {
		return null;
	}

	const { className, attributes, setAttributes, isSelected, clientId, context } = props;

	const quizID = context['quiz-master-next/quizID'];
	
	const {
		pageID,
		pageKey,
		hidePrevBtn,
	} = attributes;

	const [ qsmPageAttr, setQsmPageAttr ] = useState( qsmBlockData.globalQuizsetting );
	
	const blockProps = useBlockProps();

	return (
	<>
	<InspectorControls>
		<PanelBody title={ __( 'Page settings', 'quiz-master-next' ) } initialOpen={ true }>
			<TextControl
				label={ __( 'Page Name', 'quiz-master-next' ) }
				value={ pageKey }
				onChange={ ( pageKey ) => setAttributes( { pageKey } ) }
			/>
			<ToggleControl
				label={ __( 'Hide Previous Button?', 'quiz-master-next' ) }
				checked={ ! qsmIsEmpty( hidePrevBtn ) && '1' == hidePrevBtn  }
				onChange={ () => setAttributes( { hidePrevBtn : ( ( ! qsmIsEmpty( hidePrevBtn ) && '1' == hidePrevBtn ) ? 0 : 1 ) } ) }
			/>
		</PanelBody>
		
	</InspectorControls>
	<div { ...blockProps }>
		<InnerBlocks
			allowedBlocks={ ['qsm/quiz-question'] }
		/>
	</div>
	</>
	);
}