Add step buttons to manipulation step
[MAILPOET-1809]
This commit is contained in:
@@ -10,15 +10,46 @@ import StepDataManipulation from './import/step_data_manipulation.jsx';
|
|||||||
|
|
||||||
const container = document.getElementById('import_container');
|
const container = document.getElementById('import_container');
|
||||||
|
|
||||||
|
const subscribersLimitForValidation = 500;
|
||||||
|
|
||||||
const ImportSubscribers = () => {
|
const ImportSubscribers = () => {
|
||||||
const [stepMethodSelection, setStepMethodSelection] = useState(undefined);
|
const [stepMethodSelection, setStepMethodSelection] = useState(undefined);
|
||||||
return (
|
return (
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/step_method_selection" render={props => <StepMethodSelection {...props} setStepMethodSelection={setStepMethodSelection} />} />
|
<Route
|
||||||
<Route path="/step_input_validation" render={props => <StepInputValidation {...props} stepMethodSelection={stepMethodSelection} />} />
|
path="/step_method_selection"
|
||||||
<Route path="/step_data_manipulation" render={props => <StepDataManipulation {...props} stepMethodSelection={stepMethodSelection} />} />
|
render={props => (
|
||||||
<Route path="*" render={() => <Redirect to="/step_method_selection" />} />
|
<StepMethodSelection
|
||||||
|
{...props}
|
||||||
|
setStepMethodSelection={setStepMethodSelection}
|
||||||
|
subscribersLimitForValidation={subscribersLimitForValidation}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/step_input_validation"
|
||||||
|
render={props => (
|
||||||
|
<StepInputValidation
|
||||||
|
{...props}
|
||||||
|
stepMethodSelection={stepMethodSelection}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/step_data_manipulation"
|
||||||
|
render={props => (
|
||||||
|
<StepDataManipulation
|
||||||
|
{...props}
|
||||||
|
stepMethodSelection={stepMethodSelection}
|
||||||
|
subscribersLimitForValidation={subscribersLimitForValidation}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="*"
|
||||||
|
render={() => <Redirect to="/step_method_selection" />}
|
||||||
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
);
|
);
|
||||||
|
@@ -1,8 +1,26 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
|
import PreviousNextStepButtons from './previous_next_step_buttons.jsx';
|
||||||
|
|
||||||
function StepDataManipulation({ history, stepMethodSelection }) {
|
function getPreviousStepLink(importData, subscribersLimitForValidation) {
|
||||||
|
if (importData === undefined) {
|
||||||
|
return 'step_method_selection';
|
||||||
|
}
|
||||||
|
if (importData.subscribersCount === undefined) {
|
||||||
|
return 'step_method_selection';
|
||||||
|
}
|
||||||
|
if (importData.subscribersCount < subscribersLimitForValidation) {
|
||||||
|
return 'step_method_selection';
|
||||||
|
}
|
||||||
|
return 'step_input_validation';
|
||||||
|
}
|
||||||
|
|
||||||
|
function StepDataManipulation({
|
||||||
|
history,
|
||||||
|
stepMethodSelection,
|
||||||
|
subscribersLimitForValidation,
|
||||||
|
}) {
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (typeof (stepMethodSelection) === 'undefined') {
|
if (typeof (stepMethodSelection) === 'undefined') {
|
||||||
@@ -14,7 +32,13 @@ function StepDataManipulation({ history, stepMethodSelection }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<PreviousNextStepButtons
|
||||||
|
canGoNext={false}
|
||||||
|
onPreviousAction={() => (
|
||||||
|
history.push(getPreviousStepLink(stepMethodSelection, subscribersLimitForValidation))
|
||||||
|
)}
|
||||||
|
onNextAction={() => history.push('todo')}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -32,6 +56,7 @@ StepDataManipulation.propTypes = {
|
|||||||
subscribersCount: PropTypes.number,
|
subscribersCount: PropTypes.number,
|
||||||
subscribers: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
|
subscribers: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
|
||||||
}),
|
}),
|
||||||
|
subscribersLimitForValidation: PropTypes.number.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
StepDataManipulation.defaultProps = {
|
StepDataManipulation.defaultProps = {
|
||||||
|
@@ -8,16 +8,14 @@ import MethodUpload from './step_method_selection/method_upload.jsx';
|
|||||||
import MethodMailChimp from './step_method_selection/method_mailchimp.jsx';
|
import MethodMailChimp from './step_method_selection/method_mailchimp.jsx';
|
||||||
import processCsv from './step_method_selection/process_csv.jsx';
|
import processCsv from './step_method_selection/process_csv.jsx';
|
||||||
|
|
||||||
const SUBSCRIBERS_LIMIT_FOR_VALIDATION = 500;
|
const getNextStepLink = (importData, subscribersLimitForValidation) => {
|
||||||
|
|
||||||
const getNextStepLink = (importData) => {
|
|
||||||
if (importData === undefined) {
|
if (importData === undefined) {
|
||||||
return 'step_data_manipulation';
|
return 'step_data_manipulation';
|
||||||
}
|
}
|
||||||
if (importData.subscribersCount === undefined) {
|
if (importData.subscribersCount === undefined) {
|
||||||
return 'step_data_manipulation';
|
return 'step_data_manipulation';
|
||||||
}
|
}
|
||||||
if (importData.subscribersCount < SUBSCRIBERS_LIMIT_FOR_VALIDATION) {
|
if (importData.subscribersCount < subscribersLimitForValidation) {
|
||||||
return 'step_data_manipulation';
|
return 'step_data_manipulation';
|
||||||
}
|
}
|
||||||
return 'step_input_validation';
|
return 'step_input_validation';
|
||||||
@@ -26,6 +24,7 @@ const getNextStepLink = (importData) => {
|
|||||||
function StepMethodSelection({
|
function StepMethodSelection({
|
||||||
history,
|
history,
|
||||||
setStepMethodSelection,
|
setStepMethodSelection,
|
||||||
|
subscribersLimitForValidation,
|
||||||
}) {
|
}) {
|
||||||
const [method, setMethod] = useState(undefined);
|
const [method, setMethod] = useState(undefined);
|
||||||
const [pastedCsvData, setPastedCsvData] = useState('');
|
const [pastedCsvData, setPastedCsvData] = useState('');
|
||||||
@@ -33,7 +32,7 @@ function StepMethodSelection({
|
|||||||
|
|
||||||
const finish = (parsedData) => {
|
const finish = (parsedData) => {
|
||||||
setStepMethodSelection(parsedData);
|
setStepMethodSelection(parsedData);
|
||||||
history.push(getNextStepLink(parsedData));
|
history.push(getNextStepLink(parsedData, subscribersLimitForValidation));
|
||||||
};
|
};
|
||||||
|
|
||||||
const processLocal = () => {
|
const processLocal = () => {
|
||||||
@@ -95,6 +94,7 @@ StepMethodSelection.propTypes = {
|
|||||||
push: PropTypes.func.isRequired,
|
push: PropTypes.func.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
setStepMethodSelection: PropTypes.func.isRequired,
|
setStepMethodSelection: PropTypes.func.isRequired,
|
||||||
|
subscribersLimitForValidation: PropTypes.number.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withRouter(StepMethodSelection);
|
export default withRouter(StepMethodSelection);
|
||||||
|
Reference in New Issue
Block a user