2023-09-27 19:48:59 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { render, createRoot } from '@wordpress/element';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { RegionPicker } from './region-picker';
|
2023-10-24 22:51:52 +00:00
|
|
|
import { ShippingCurrencyContext } from './currency-context';
|
2023-09-27 19:48:59 +00:00
|
|
|
|
|
|
|
const shippingZoneRegionPickerRoot = document.getElementById(
|
|
|
|
'wc-shipping-zone-region-picker-root'
|
|
|
|
);
|
|
|
|
|
|
|
|
const options = window.shippingZoneMethodsLocalizeScript?.region_options ?? [];
|
|
|
|
const initialValues = window.shippingZoneMethodsLocalizeScript?.locations ?? [];
|
|
|
|
|
2023-10-24 22:51:52 +00:00
|
|
|
const ShippingApp = () => (
|
|
|
|
<div>
|
|
|
|
<ShippingCurrencyContext />
|
|
|
|
<RegionPicker options={ options } initialValues={ initialValues } />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2023-09-27 19:48:59 +00:00
|
|
|
if ( shippingZoneRegionPickerRoot ) {
|
|
|
|
if ( createRoot ) {
|
2023-10-24 22:51:52 +00:00
|
|
|
createRoot( shippingZoneRegionPickerRoot ).render( <ShippingApp /> );
|
2023-09-27 19:48:59 +00:00
|
|
|
} else {
|
2023-10-24 22:51:52 +00:00
|
|
|
render( <ShippingApp />, shippingZoneRegionPickerRoot );
|
2023-09-27 19:48:59 +00:00
|
|
|
}
|
|
|
|
}
|