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>
<SubscribersCounter />
<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')}
</Button>
</div>

View File

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

View File

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