Save the re-engagement email
[MAILPOET-3763]
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { __, assoc, compose } from 'lodash/fp';
|
import { __, assoc, compose } from 'lodash/fp';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
import Background from 'common/background/background';
|
import Background from 'common/background/background';
|
||||||
import { Grid } from 'common/grid';
|
import { Grid } from 'common/grid';
|
||||||
import Button from 'common/button/button';
|
import Button from 'common/button/button';
|
||||||
import ListingHeadingStepsRoute from '../../listings/heading_steps_route';
|
import APIErrorsNotice from 'notices/api_errors_notice';
|
||||||
|
|
||||||
import { Scheduling } from './scheduling';
|
import { Scheduling } from './scheduling';
|
||||||
|
import ListingHeadingStepsRoute from '../../listings/heading_steps_route';
|
||||||
|
|
||||||
interface ReengagementWindow extends Window {
|
interface ReengagementWindow extends Window {
|
||||||
settings: {
|
settings: {
|
||||||
@@ -23,10 +26,39 @@ export function NewsletterTypeReEngagement(): JSX.Element {
|
|||||||
).toString(),
|
).toString(),
|
||||||
afterTimeType: 'months',
|
afterTimeType: 'months',
|
||||||
});
|
});
|
||||||
|
const [errors, setErrors] = useState([]);
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
function showTemplateSelection(newsletterId: string) {
|
||||||
|
history.push(`/template/${newsletterId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNext() {
|
||||||
|
setErrors([]);
|
||||||
|
MailPoet.Ajax.post({
|
||||||
|
api_version: MailPoet.apiVersion,
|
||||||
|
endpoint: 'newsletters',
|
||||||
|
action: 'create',
|
||||||
|
data: {
|
||||||
|
type: 're_engagement',
|
||||||
|
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||||
|
options,
|
||||||
|
},
|
||||||
|
}).done((response) => {
|
||||||
|
showTemplateSelection(response.data.id);
|
||||||
|
}).fail((response) => {
|
||||||
|
if (response.errors) {
|
||||||
|
setErrors(response.errors);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Background color="#fff" />
|
<Background color="#fff" />
|
||||||
|
|
||||||
|
{errors && (<APIErrorsNotice errors={errors} />)}
|
||||||
|
|
||||||
<ListingHeadingStepsRoute emailType="re_engagement" automationId="re_engagement_heading_creation_heading" />
|
<ListingHeadingStepsRoute emailType="re_engagement" automationId="re_engagement_heading_creation_heading" />
|
||||||
|
|
||||||
<Grid.Column align="center" className="mailpoet-schedule-email">
|
<Grid.Column align="center" className="mailpoet-schedule-email">
|
||||||
@@ -42,7 +74,7 @@ export function NewsletterTypeReEngagement(): JSX.Element {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
isFullWidth
|
isFullWidth
|
||||||
onClick={() => 5}
|
onClick={handleNext}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{MailPoet.I18n.t('next')}
|
{MailPoet.I18n.t('next')}
|
||||||
|
@@ -425,32 +425,41 @@ class Populator {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'group',
|
'name' => 'group',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'event',
|
'name' => 'event',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'sendTo',
|
'name' => 'sendTo',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'segment',
|
'name' => 'segment',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'afterTimeNumber',
|
'name' => 'afterTimeNumber',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'afterTimeType',
|
'name' => 'afterTimeType',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'meta',
|
'name' => 'meta',
|
||||||
'newsletter_type' => Newsletter::TYPE_AUTOMATIC,
|
'newsletter_type' => NewsletterEntity::TYPE_AUTOMATIC,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'afterTimeNumber',
|
||||||
|
'newsletter_type' => NewsletterEntity::TYPE_RE_ENGAGEMENT,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'afterTimeType',
|
||||||
|
'newsletter_type' => NewsletterEntity::TYPE_RE_ENGAGEMENT,
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@@ -28,6 +28,7 @@ class NewsletterEntity {
|
|||||||
const TYPE_NOTIFICATION = 'notification';
|
const TYPE_NOTIFICATION = 'notification';
|
||||||
const TYPE_NOTIFICATION_HISTORY = 'notification_history';
|
const TYPE_NOTIFICATION_HISTORY = 'notification_history';
|
||||||
const TYPE_WC_TRANSACTIONAL_EMAIL = 'wc_transactional';
|
const TYPE_WC_TRANSACTIONAL_EMAIL = 'wc_transactional';
|
||||||
|
const TYPE_RE_ENGAGEMENT = 're_engagement';
|
||||||
|
|
||||||
// standard newsletters
|
// standard newsletters
|
||||||
const STATUS_DRAFT = 'draft';
|
const STATUS_DRAFT = 'draft';
|
||||||
|
@@ -365,6 +365,7 @@
|
|||||||
'stepNameTypeWelcome': __('Welcome Email'),
|
'stepNameTypeWelcome': __('Welcome Email'),
|
||||||
'stepNameTypeNotification': __('Post Notification'),
|
'stepNameTypeNotification': __('Post Notification'),
|
||||||
'stepNameTypeWooCommerce': __('WooCommerce'),
|
'stepNameTypeWooCommerce': __('WooCommerce'),
|
||||||
|
'stepNameTypeReEngagement': __('Re-engagement'),
|
||||||
'stepNameTemplate': __('Template'),
|
'stepNameTemplate': __('Template'),
|
||||||
'stepNameDesign': __('Design'),
|
'stepNameDesign': __('Design'),
|
||||||
'stepNameSend': __('Send'),
|
'stepNameSend': __('Send'),
|
||||||
|
Reference in New Issue
Block a user