Fix redirection after save

[MAILPOET-3231]
This commit is contained in:
Pavel Dohnal
2021-05-31 15:30:32 +02:00
committed by Veljko V
parent a0d71c0e14
commit ba1b4d0172
3 changed files with 14 additions and 4 deletions

View File

@@ -134,7 +134,14 @@ export const Form: React.FunctionComponent<Props> = ({
</div> </div>
<SubscribersCounter /> <SubscribersCounter />
<div className="mailpoet-form-actions"> <div className="mailpoet-form-actions">
<Button type="submit" onClick={(): void => { handleSave(segmentId); }} isDisabled={!isFormValid(segment)}> <Button
type="submit"
onClick={(e): void => {
e.preventDefault();
handleSave(segmentId);
}}
isDisabled={!isFormValid(segment)}
>
{MailPoet.I18n.t('save')} {MailPoet.I18n.t('save')}
</Button> </Button>
</div> </div>

View File

@@ -56,7 +56,7 @@ export function* pageLoaded(segmentId?: number): Generator<{
segmentId, segmentId,
})); }));
if (!success || res.is_plugin_missing) { if (!success || res.is_plugin_missing) {
window.location.href = '#/segments'; window.location.href = 'admin.php?page=mailpoet-segments#/segments';
} }
yield setSegment(res); yield setSegment(res);
MailPoet.Modal.loading(false); MailPoet.Modal.loading(false);
@@ -90,7 +90,7 @@ export function* handleSave(segmentId?: number): Generator<{
})); }));
if (success) { if (success) {
window.location.href = '#/segments'; window.location.href = 'admin.php?page=mailpoet-segments#/segments';
if (segmentId !== undefined) { if (segmentId !== undefined) {
messages.onUpdate(); messages.onUpdate();

View File

@@ -11,6 +11,7 @@ import * as controls from './controls';
import { import {
StateType, StateType,
SegmentFormDataWindow, SegmentFormDataWindow,
SegmentTypes,
} from '../types'; } from '../types';
declare let window: SegmentFormDataWindow; declare let window: SegmentFormDataWindow;
@@ -27,7 +28,9 @@ export const createStore = (): void => {
wooCurrencySymbol: window.mailpoet_woocommerce_currency_symbol, wooCurrencySymbol: window.mailpoet_woocommerce_currency_symbol,
wooCountries: window.mailpoet_woocommerce_countries, wooCountries: window.mailpoet_woocommerce_countries,
customFieldsList: window.mailpoet_custom_fields, customFieldsList: window.mailpoet_custom_fields,
segment: {}, segment: {
segmentType: SegmentTypes.WordPressRole,
},
errors: [], errors: [],
}; };