Add data mappers for divider block

[MAILPOET-2462]
This commit is contained in:
Rostislav Wolny
2019-12-10 14:42:37 +01:00
committed by Pavel Dohnal
parent 275eeb498e
commit 15b66febc6
4 changed files with 71 additions and 2 deletions

View File

@@ -74,6 +74,15 @@ export default (blocks) => {
type: 'submit',
name: 'Submit',
};
case 'mailpoet-form/divider':
return {
...mapped,
id: 'divider',
type: 'divider',
name: 'Divider',
static: '0',
params: '',
};
default:
return null;
}

View File

@@ -6,7 +6,7 @@ export default (data) => {
if (!Array.isArray(data)) {
throw new Error('Mapper expects form body to be an array.');
}
return data.map((item) => {
return data.map((item, index) => {
const mapped = {
clientId: item.id,
isValid: true,
@@ -64,6 +64,12 @@ export default (data) => {
...mapped,
name: 'mailpoet-form/submit-button',
};
case 'divider':
return {
...mapped,
name: 'mailpoet-form/divider',
clientId: `divider_${index}`,
};
default:
return null;
}