diff --git a/assets/js/src/form_editor/blocks/segment_select/edit.jsx b/assets/js/src/form_editor/blocks/segment_select/edit.jsx
index 3bd5ce3047..5fa80c929d 100644
--- a/assets/js/src/form_editor/blocks/segment_select/edit.jsx
+++ b/assets/js/src/form_editor/blocks/segment_select/edit.jsx
@@ -4,12 +4,40 @@ import {
PanelBody,
TextControl,
CheckboxControl,
+ SelectControl,
+ BaseControl,
} from '@wordpress/components';
import { InspectorControls } from '@wordpress/block-editor';
+import { useSelect } from '@wordpress/data';
import PropTypes from 'prop-types';
import MailPoet from 'mailpoet';
const SegmentSelectEdit = ({ attributes, setAttributes }) => {
+ const allSegments = useSelect(
+ (select) => select('mailpoet-form-editor').getAllAvailableSegments(),
+ []
+ );
+
+ const segmentsListToBeAdded = allSegments.map((segment) => ({
+ label: segment.name,
+ value: segment.id,
+ }))
+ .filter((segment) => !attributes.values.find((s) => s.id === segment.value));
+
+ const addSegment = (segmentId) => {
+ const segment = allSegments.find((s) => s.id === segmentId);
+ setAttributes({
+ values: [
+ ...attributes.values,
+ {
+ name: segment.name,
+ isChecked: false,
+ id: segmentId,
+ },
+ ],
+ });
+ };
+
const inspectorControls = (
- {attributes.label} -
+