Add mapper for mapping form body to blocks
[MAILPOET-2451]
This commit is contained in:
committed by
Jack Kitterhing
parent
293956bbec
commit
4e71908332
26
assets/js/src/form_editor/store/form_body_to_blocks.jsx
Normal file
26
assets/js/src/form_editor/store/form_body_to_blocks.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
export default (data) => (
|
||||
data.map((item) => {
|
||||
const mapped = {
|
||||
clientId: item.id,
|
||||
isValid: true,
|
||||
innerBlocks: [],
|
||||
};
|
||||
switch (item.id) {
|
||||
case 'email':
|
||||
mapped.name = 'mailpoet-form/email-input';
|
||||
mapped.attributes = {
|
||||
label: item.params.label,
|
||||
labelWithinInput: !!item.params.label_within,
|
||||
};
|
||||
return mapped;
|
||||
case 'submit':
|
||||
mapped.name = 'mailpoet-form/submit-button';
|
||||
mapped.attributes = {
|
||||
label: item.params.label,
|
||||
};
|
||||
return mapped;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}).filter(Boolean)
|
||||
);
|
Reference in New Issue
Block a user