Ask user to update existing subscribers
[MAILPOET-1809]
This commit is contained in:
@@ -15,32 +15,12 @@ import StepResults from './import/step_results.jsx';
|
||||
jQuery(document).ready(() => {
|
||||
|
||||
router.on('route:step_data_manipulation', () => {
|
||||
let fillerPosition;
|
||||
|
||||
// define reusable variables
|
||||
const nextStepButton = jQuery('#next_step');
|
||||
|
||||
// create a copy of subscribers object for further manipulation
|
||||
const subscribers = jQuery.extend(true, {}, window.importData.step_method_selection);
|
||||
const subscribersDataTemplate = Handlebars.compile(jQuery('#subscribers_data_template').html());
|
||||
const subscribersDataTemplatePartial = Handlebars.compile(jQuery('#subscribers_data_template_partial').html());
|
||||
const segmentSelectElement = jQuery('#mailpoet_segments_select');
|
||||
const maxRowsToShow = 10;
|
||||
const filler = '. . .';
|
||||
// create an array of filler data with the same number of
|
||||
// elements as in the subscribers' data row
|
||||
const fillerArray = Array(...new Array(subscribers.subscribers[0].length))
|
||||
.map(String.prototype.valueOf, filler);
|
||||
|
||||
function toggleNextStepButton(condition) {
|
||||
const disabled = 'button-disabled';
|
||||
if (condition === 'on') {
|
||||
nextStepButton.removeClass(disabled);
|
||||
return;
|
||||
}
|
||||
nextStepButton.addClass(disabled);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nextStepButton.off().on('click', (event) => {
|
||||
|
@@ -5,6 +5,7 @@ import PreviousNextStepButtons from './previous_next_step_buttons.jsx';
|
||||
import Warnings from './step_data_manipulation/warnings.jsx';
|
||||
import MatchTable from './step_data_manipulation/match_table.jsx';
|
||||
import SelectSegment from './step_data_manipulation/select_segment.jsx';
|
||||
import UpdateExistingSubscribers from './step_data_manipulation/update_existing_subscribers.jsx';
|
||||
|
||||
function getPreviousStepLink(importData, subscribersLimitForValidation) {
|
||||
if (importData === undefined) {
|
||||
@@ -25,6 +26,7 @@ function StepDataManipulation({
|
||||
subscribersLimitForValidation,
|
||||
}) {
|
||||
const [selectedSegments, setSelectedSegments] = useState([]);
|
||||
const [updateExistingSubscribers, setUpdateExistingSubscribers] = useState(true);
|
||||
useEffect(
|
||||
() => {
|
||||
if (typeof (stepMethodSelectionData) === 'undefined') {
|
||||
@@ -49,6 +51,10 @@ function StepDataManipulation({
|
||||
header={stepMethodSelectionData.header}
|
||||
/>
|
||||
<SelectSegment setSelectedSegments={setSelectedSegments} />
|
||||
<UpdateExistingSubscribers
|
||||
setUpdateExistingSubscribers={setUpdateExistingSubscribers}
|
||||
updateExistingSubscribers={updateExistingSubscribers}
|
||||
/>
|
||||
</div>
|
||||
<PreviousNextStepButtons
|
||||
canGoNext={selectedSegments.length > 0}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import MailPoet from 'mailpoet';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
function UpdateExistingSubscribers({ updateExistingSubscribers, setUpdateExistingSubscribers }) {
|
||||
return (
|
||||
<>
|
||||
{MailPoet.I18n.t('updateExistingSubscribers')}
|
||||
<label htmlFor="update_existing_subscribers">
|
||||
<input
|
||||
id="update_existing_subscribers"
|
||||
type="radio"
|
||||
name="update_existing_subscribers"
|
||||
checked={updateExistingSubscribers}
|
||||
onChange={() => setUpdateExistingSubscribers(true)}
|
||||
/>
|
||||
{MailPoet.I18n.t('updateExistingSubscribersYes')}
|
||||
</label>
|
||||
<label htmlFor="dont_update_existing_subscribers">
|
||||
<input
|
||||
id="dont_update_existing_subscribers"
|
||||
type="radio"
|
||||
name="update_existing_subscribers"
|
||||
checked={!updateExistingSubscribers}
|
||||
onChange={() => setUpdateExistingSubscribers(false)}
|
||||
/>
|
||||
{MailPoet.I18n.t('updateExistingSubscribersNo')}
|
||||
</label>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
UpdateExistingSubscribers.propTypes = {
|
||||
setUpdateExistingSubscribers: PropTypes.func.isRequired,
|
||||
updateExistingSubscribers: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
export default UpdateExistingSubscribers;
|
Reference in New Issue
Block a user