/**
 * RawType Order Exporter admin bootstrap.
 *
 * @package RawTypeOE
 */

import apiFetch from '@wordpress/api-fetch';
import { createRoot } from '@wordpress/element';
import App from './App';
import './styles/admin.css';

const rootElement = document.getElementById( 'rawtype-oe-root' );
const appConfig = window.rawtypeOEAdmin || {};

if ( appConfig.restUrl ) {
	apiFetch.use( apiFetch.createRootURLMiddleware( appConfig.restUrl ) );
}

if ( appConfig.nonce ) {
	apiFetch.use( apiFetch.createNonceMiddleware( appConfig.nonce ) );
}

if ( rootElement ) {
	const root = createRoot( rootElement );
	root.render( <App /> );
}
