Commit 221d1663 authored by Andrei Mondoc's avatar Andrei Mondoc
Browse files

remove unused assets

parent 8c92ad24
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Block Dependencies.
*
* @since 0.1
*/
import Select from 'react-select';
/**
* Internal Block Libraries.
*
* @since 0.1
*/
const { apiFetch } = wp;
const { __ } = wp.i18n;
const {
//registerStore,
withSelect,
} = wp.data;
const { registerBlockType } = wp.blocks;
const { InspectorControls } = wp.editor;
const {
ServerSideRender,
TextControl,
SelectControl,
ToggleControl,
PanelBody,
} = wp.components;
console.log('here');
/**
* Dynamic actions.
*
* @since 0.1
*/
/*
const actions = {
setUserRoles( userRoles ) {
console.log( `actions userRoles:`, userRoles );
return {
type: 'SET_USER_ROLES',
userRoles,
};
},
getUserRoles( path ) {
console.log( `actions path:`, path );
return {
type: 'GET_USER_ROLES',
path,
};
},
};
*/
/**
* Dynamic data store.
*
* @since 0.1
*/
/*
const store = registerStore(
'civicrm/civicrm-profile-block', {
reducer( state = { userRoles: {} }, action ) {
console.log( `reducer action:`, action );
switch ( action.type ) {
case 'SET_USER_ROLES':
return {
...state,
userRoles: action.userRoles,
};
case 'GET_USER_ROLES':
return action.userRoles;
}
return state;
},
actions,
selectors: {
getUserRoles( state ) {
console.log( `selectors state:`, state );
const { userRoles } = state;
return userRoles;
},
},
resolvers: {
* getUserRoles( state ) {
console.log( `resolvers state:`, state );
const userRoles = apiFetch( { path: '/civicrm/civicrm-profile-block/v1/user-roles/' } )
.then( userRoles => {
return actions.setUserRoles( userRoles );
} )
yield userRoles;
},
},
}
);
*/
/**
* Register block.
*
* @since 0.1
*/
export default registerBlockType(
'civicrm/civicrm-profile-block', {
title: __( 'CiviCRM Profile', 'civicrm-gutenberg-blocks' ),
description: __( 'Demonstration of a CiviCRM Profile block.', 'civicrm-gutenberg-blocks' ),
category: 'widgets',
icon: 'megaphone',
keywords: [
__( 'CiviCRM', 'civicrm-gutenberg-blocks' ),
__( 'Profile', 'civicrm-gutenberg-blocks' ),
],
edit: /* withSelect( ( select ) => {
return {
userRoles: select( 'civicrm/civicrm-profile-block' ).getUserRoles(),
};
} )( */ props => {
const { attributes, userRoles, className, setAttributes } = props;
const { component, gid, mode, hijack } = props.attributes;
console.log( `userRoles:`, userRoles );
const handleSelectChange = ( selectedOption ) => {
setAttributes( { gid: selectedOption.value } );
};
const defaultOptions = [
{ value: '1', label: 'One' },
{ value: '2', label: 'Two' },
{ value: '3', label: 'Three' },
];
return (
<div>
<ServerSideRender
block="civicrm/civicrm-profile-block"
attributes={ attributes }
/>
<InspectorControls>
<PanelBody>
<SelectControl
label={ __( 'Mode', 'civicrm-gutenberg-blocks' ) }
value={ mode }
options={[
{ value: 'test', label: __( 'Test Drive', 'civicrm-gutenberg-blocks' ) },
{ value: 'live', label: __( 'Live Mode', 'civicrm-gutenberg-blocks' ) },
]}
onChange={ mode => setAttributes( { mode } ) }
/>
</PanelBody>
<PanelBody>
<ToggleControl
label={ __( 'Hijack', 'civicrm-gutenberg-blocks' ) }
checked={ hijack }
onChange={ hijack => setAttributes( { hijack } ) }
/>
</PanelBody>
</InspectorControls>
</div>
);
}, // ),
save: props => {
return null;
},
},
);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment