Fix compatibility to allow compilation

[MAILPOET-4301]
This commit is contained in:
Jan Lysý 2022-07-28 14:22:23 +02:00 committed by Veljko V
parent 2ae02db229
commit c37173a30e
37 changed files with 187 additions and 144 deletions

View File

@ -22,7 +22,7 @@ export function KeyboardShortcuts(): null {
const { registerShortcut } = useDispatch(keyboardShortcutsStore);
useEffect(() => {
registerShortcut({
void registerShortcut({
name: 'mailpoet/automation-editor/toggle-fullscreen',
category: 'global',
description: __('Toggle fullscreen mode.'),
@ -32,7 +32,7 @@ export function KeyboardShortcuts(): null {
},
});
registerShortcut({
void registerShortcut({
name: 'mailpoet/automation-editor/toggle-sidebar',
category: 'global',
description: __('Show or hide the settings sidebar.'),

View File

@ -17,7 +17,9 @@ export function BelowPages(): JSX.Element {
active={formSettings.formPlacement.belowPosts.enabled}
label={MailPoet.I18n.t('placeFormBellowPages')}
icon={BelowPageIcon}
onClick={(): void => showPlacementSettings('below_posts')}
onClick={(): void => {
void showPlacementSettings('below_posts');
}}
canBeActive
/>
);

View File

@ -16,7 +16,9 @@ export function FixedBar(): JSX.Element {
active={formSettings.formPlacement.fixedBar.enabled}
label={MailPoet.I18n.t('placeFixedBarFormOnPages')}
icon={FixedBarIcon}
onClick={(): void => showPlacementSettings('fixed_bar')}
onClick={(): void => {
void showPlacementSettings('fixed_bar');
}}
canBeActive
/>
);

View File

@ -11,7 +11,9 @@ export function Other(): JSX.Element {
active={false}
label={MailPoet.I18n.t('formPlacementOtherLabel')}
icon={SidebarIcon}
onClick={(): void => showPlacementSettings('others')}
onClick={(): void => {
void showPlacementSettings('others');
}}
canBeActive={false}
/>
);

View File

@ -16,7 +16,9 @@ export function Popup(): JSX.Element {
active={formSettings.formPlacement.popup.enabled}
label={MailPoet.I18n.t('placePopupFormOnPages')}
icon={PopupIcon}
onClick={(): void => showPlacementSettings('popup')}
onClick={(): void => {
void showPlacementSettings('popup');
}}
canBeActive
/>
);

View File

@ -36,15 +36,15 @@ export function BelowPostsSettings(): JSX.Element {
maxPercents={100}
defaultPixelValue={560}
defaultPercentValue={100}
onChange={(width): void =>
changeFormSettings(
onChange={(width): void => {
void changeFormSettings(
assocPath(
'formPlacement.belowPosts.styles.width',
width,
formSettings,
),
)
}
);
}}
/>
<PlacementSettings settingsPlacementKey="belowPosts" />
</>

View File

@ -63,15 +63,15 @@ export function FixedBarSettings(): JSX.Element {
maxPercents={100}
defaultPixelValue={560}
defaultPercentValue={100}
onChange={(width): void =>
changeFormSettings(
onChange={(width): void => {
void changeFormSettings(
assocPath(
'formPlacement.fixedBar.styles.width',
width,
formSettings,
),
)
}
);
}}
/>
<PlacementSettings settingsPlacementKey="fixedBar" />
<AnimationSettings settingsPlacementKey="fixedBar" />

View File

@ -108,11 +108,11 @@ export function OtherSettings(): JSX.Element {
maxPercents={100}
defaultPixelValue={200}
defaultPercentValue={100}
onChange={(width): void =>
changeFormSettings(
onChange={(width): void => {
void changeFormSettings(
assocPath('formPlacement.others.styles.width', width, formSettings),
)
}
);
}}
/>
</>
);

View File

@ -42,15 +42,15 @@ export function PopUpSettings(): JSX.Element {
maxPercents={100}
defaultPixelValue={560}
defaultPercentValue={100}
onChange={(width): void =>
changeFormSettings(
onChange={(width): void => {
void changeFormSettings(
assocPath(
'formPlacement.popup.styles.width',
width,
formSettings,
),
)
}
);
}}
/>
<PlacementSettings settingsPlacementKey="popup" />
<AnimationSettings settingsPlacementKey="popup" />

View File

@ -63,15 +63,15 @@ export function SlideInSettings(): JSX.Element {
maxPercents={100}
defaultPixelValue={560}
defaultPercentValue={100}
onChange={(width): void =>
changeFormSettings(
onChange={(width): void => {
void changeFormSettings(
assocPath(
'formPlacement.slideIn.styles.width',
width,
formSettings,
),
)
}
);
}}
/>
<PlacementSettings settingsPlacementKey="slideIn" />
<AnimationSettings settingsPlacementKey="slideIn" />

View File

@ -16,7 +16,9 @@ export function SlideIn(): JSX.Element {
active={formSettings.formPlacement.slideIn.enabled}
label={MailPoet.I18n.t('placeSlideInFormOnPages')}
icon={SlideInIcon}
onClick={(): void => showPlacementSettings('slide_in')}
onClick={(): void => {
void showPlacementSettings('slide_in');
}}
canBeActive
/>
);

View File

@ -15,7 +15,7 @@ export function HistoryRedo(props: Record<string, unknown>): JSX.Element {
const { registerShortcut } = useDispatch('core/keyboard-shortcuts');
const redoAction = (): void => {
historyRedo();
void historyRedo();
};
useShortcut(

View File

@ -15,7 +15,7 @@ export function HistoryUndo(props: Record<string, unknown>): JSX.Element {
const { registerShortcut } = useDispatch('core/keyboard-shortcuts');
const undoAction = (): void => {
historyUndo();
void historyUndo();
};
useShortcut(
@ -23,7 +23,7 @@ export function HistoryUndo(props: Record<string, unknown>): JSX.Element {
'mailpoet-form-editor/undo',
// Shortcut callback
(event): void => {
historyUndo();
void historyUndo();
event.preventDefault();
},
);

View File

@ -75,20 +75,20 @@ export function FormPreview(): JSX.Element {
if (beacon) {
beacon.style.display = 'block';
}
hidePreview();
void hidePreview();
}, [hidePreview]);
const setFormType = useCallback(
(type): void => {
setIframeLoaded(false);
changePreviewSettings({ ...previewSettings, formType: type });
void changePreviewSettings({ ...previewSettings, formType: type });
},
[changePreviewSettings, previewSettings],
);
const onPreviewTypeChange = useCallback(
(type): void => {
changePreviewSettings({ ...previewSettings, displayType: type });
void changePreviewSettings({ ...previewSettings, displayType: type });
},
[changePreviewSettings, previewSettings],
);

View File

@ -26,9 +26,9 @@ export function DefaultSidebar({ onClose }: Props): JSX.Element {
useEffect(() => {
if (selectedBlockId) {
switchDefaultSidebarTab('block');
void switchDefaultSidebarTab('block');
} else {
switchDefaultSidebarTab('form');
void switchDefaultSidebarTab('form');
}
}, [selectedBlockId, switchDefaultSidebarTab]);
@ -38,7 +38,9 @@ export function DefaultSidebar({ onClose }: Props): JSX.Element {
<ul>
<li>
<button
onClick={(): void => switchDefaultSidebarTab('form')}
onClick={(): void => {
void switchDefaultSidebarTab('form');
}}
className={classnames(
'components-button edit-post-sidebar__panel-tab',
{ 'is-active': activeTab === 'form' },
@ -51,7 +53,9 @@ export function DefaultSidebar({ onClose }: Props): JSX.Element {
</li>
<li>
<button
onClick={(): void => switchDefaultSidebarTab('block')}
onClick={(): void => {
void switchDefaultSidebarTab('block');
}}
className={classnames(
'components-button edit-post-sidebar__panel-tab',
{ 'is-active': activeTab === 'block' },

View File

@ -14,7 +14,7 @@ export function Sidebar(): JSX.Element {
);
const closePlacementSettings = (): void => {
changeActiveSidebar('default');
void changeActiveSidebar('default');
};
const selectedBlockId = useSelect(
@ -26,13 +26,17 @@ export function Sidebar(): JSX.Element {
if (!selectedBlockId) {
return;
}
changeActiveSidebar('default');
void changeActiveSidebar('default');
}, [selectedBlockId, changeActiveSidebar]);
return (
<div className="edit-post-sidebar interface-complementary-area mailpoet_form_editor_sidebar">
{activeSidebar === 'default' && (
<DefaultSidebar onClose={(): void => toggleSidebar(false)} />
<DefaultSidebar
onClose={(): void => {
void toggleSidebar(false);
}}
/>
)}
{activeSidebar === 'placement_settings' && (
<PlacementSettingsSidebar onClose={closePlacementSettings} />

View File

@ -17,7 +17,7 @@ export function Tutorial(): JSX.Element {
const { tutorialDismissed } = useDispatch('mailpoet-form-editor');
const onClose = useCallback((): void => {
tutorialDismissed();
void tutorialDismissed();
}, [tutorialDismissed]);
if (tutorialSeen) {

View File

@ -47,7 +47,7 @@ export const controls = {
if (select('mailpoet-form-editor').getIsFormSaving()) {
return;
}
dispatch('mailpoet-form-editor').saveFormStarted();
void dispatch('mailpoet-form-editor').saveFormStarted();
const formErrors = select('mailpoet-form-editor').getFormErrors();
if (formErrors.length) {
return;
@ -75,18 +75,18 @@ export const controls = {
data: requestData,
})
.done((result) => {
dispatch('mailpoet-form-editor').saveFormDone(result.data.id);
void dispatch('mailpoet-form-editor').saveFormDone(result.data.id);
Cookies.remove(`popup_form_dismissed_${result.data.id}`, { path: '/' });
})
.fail((response) => {
dispatch('mailpoet-form-editor').saveFormFailed(
void dispatch('mailpoet-form-editor').saveFormFailed(
formatApiErrorMessage(response),
);
});
},
async SAVE_CUSTOM_FIELD(actionData) {
dispatch('mailpoet-form-editor').saveCustomFieldStarted();
void dispatch('mailpoet-form-editor').saveCustomFieldStarted();
const customFields = select(
'mailpoet-form-editor',
).getAllAvailableCustomFields();
@ -102,15 +102,15 @@ export const controls = {
data: requestData,
})
.then((response) => {
dispatch('mailpoet-form-editor').saveCustomFieldDone(
void dispatch('mailpoet-form-editor').saveCustomFieldDone(
customField.id,
response.data,
);
if (typeof actionData.onFinish === 'function') actionData.onFinish();
})
.then(dispatch('mailpoet-form-editor').saveForm)
.then(() => void dispatch('mailpoet-form-editor').saveForm())
.fail((response) => {
dispatch('mailpoet-form-editor').saveCustomFieldFailed(
void dispatch('mailpoet-form-editor').saveCustomFieldFailed(
formatApiErrorMessage(response),
);
});
@ -124,7 +124,7 @@ export const controls = {
if (select('mailpoet-form-editor').getIsCustomFieldCreating()) {
return;
}
dispatch('mailpoet-form-editor').createCustomFieldStarted(action.data);
void dispatch('mailpoet-form-editor').createCustomFieldStarted(action.data);
// Check if it really started. Could been blocked by an error.
if (!select('mailpoet-form-editor').getIsCustomFieldCreating()) {
return;
@ -143,10 +143,12 @@ export const controls = {
const blockName = registerCustomFieldBlock(customField);
const customFieldBlock = createBlock(blockName);
dispatch('core/block-editor').replaceBlock(clientId, customFieldBlock);
dispatch('mailpoet-form-editor').createCustomFieldDone(response.data);
void dispatch('mailpoet-form-editor').createCustomFieldDone(
response.data,
);
})
.fail((response) => {
dispatch('mailpoet-form-editor').createCustomFieldFailed(
void dispatch('mailpoet-form-editor').createCustomFieldFailed(
formatApiErrorMessage(response),
);
});
@ -157,7 +159,7 @@ export const controls = {
customFieldId,
clientId,
}: { customFieldId: number; clientId: string } = actionData;
dispatch('mailpoet-form-editor').deleteCustomFieldStarted();
void dispatch('mailpoet-form-editor').deleteCustomFieldStarted();
const customFields = select(
'mailpoet-form-editor',
).getAllAvailableCustomFields();
@ -175,7 +177,7 @@ export const controls = {
MailPoet.trackEvent('Forms > Delete custom field', {
'Field type': customField.type,
});
dispatch('mailpoet-form-editor').deleteCustomFieldDone(
void dispatch('mailpoet-form-editor').deleteCustomFieldDone(
customFieldId,
clientId,
);
@ -190,7 +192,7 @@ export const controls = {
dispatch('core/block-editor').removeBlock(clientId);
})
.fail((response) => {
dispatch('mailpoet-form-editor').deleteCustomFieldFailed(
void dispatch('mailpoet-form-editor').deleteCustomFieldFailed(
formatApiErrorMessage(response),
);
});
@ -240,7 +242,7 @@ export const controls = {
const emailInput = findBlock(newBlocks, 'mailpoet-form/email-input');
const submitInput = findBlock(newBlocks, 'mailpoet-form/submit-button');
if (emailInput && submitInput) {
dispatch('mailpoet-form-editor').changeFormBlocks(newBlocks);
void dispatch('mailpoet-form-editor').changeFormBlocks(newBlocks);
return;
}

View File

@ -76,7 +76,9 @@ export function Selection(): JSX.Element {
<Heading level={4}>{MailPoet.I18n.t('selectTemplate')}</Heading>
<Button
automationId="create_blank_form"
onClick={(): void => selectTemplate('initial_form', 'Blank template')}
onClick={(): void => {
void selectTemplate('initial_form', 'Blank template');
}}
>
{MailPoet.I18n.t('createBlankTemplate')}
</Button>
@ -97,7 +99,9 @@ export function Selection(): JSX.Element {
{templates[selectedCategory].map((template) => (
<TemplateBox
key={template.id}
onSelect={(): void => selectTemplate(template.id, template.name)}
onSelect={(): void => {
void selectTemplate(template.id, template.name);
}}
label={template.name}
automationId={`select_template_${template.id}`}
className="mailpoet-form-template"

View File

@ -27,7 +27,7 @@ export function Checkbox({ filterIndex }: Props): JSX.Element {
useEffect(() => {
if (segment.value !== '1' && segment.value !== '0') {
updateSegmentFilter({ operator: 'equals', value: '1' }, filterIndex);
void updateSegmentFilter({ operator: 'equals', value: '1' }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);

View File

@ -237,7 +237,7 @@ export function CustomFieldDate({
useEffect(() => {
if (segment.date_type !== customField.params.date_type) {
updateSegmentFilter(
void updateSegmentFilter(
{ date_type: customField.params.date_type, value: '' },
filterIndex,
);

View File

@ -60,7 +60,7 @@ export function RadioSelect({ filterIndex }: Props): JSX.Element {
segment.value ? { value: segment.value, label: segment.value } : null
}
onChange={(option: SelectOption): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ value: option.value, operator: 'equals' },
filterIndex,
);

View File

@ -37,7 +37,7 @@ export function Text({ filterIndex }: Props): JSX.Element {
useEffect(() => {
if (segment.operator === undefined) {
updateSegmentFilter({ operator: 'equals', value: '' }, filterIndex);
void updateSegmentFilter({ operator: 'equals', value: '' }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -48,7 +48,7 @@ export function Text({ filterIndex }: Props): JSX.Element {
automationId="text-custom-field-operator"
value={segment.operator}
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value="equals">{MailPoet.I18n.t('equals')}</option>
@ -62,7 +62,7 @@ export function Text({ filterIndex }: Props): JSX.Element {
data-automation-id="text-custom-field-value"
value={segment.value || ''}
onChange={(e) => {
updateSegmentFilterFromEvent('value', filterIndex, e);
void updateSegmentFilterFromEvent('value', filterIndex, e);
}}
placeholder={MailPoet.I18n.t('value')}
/>

View File

@ -42,7 +42,7 @@ export function EmailOpensAbsoluteCountFields({
);
useEffect(() => {
if (segment.operator === undefined) {
updateSegmentFilter({ operator: 'more' }, filterIndex);
void updateSegmentFilter({ operator: 'more' }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -56,7 +56,7 @@ export function EmailOpensAbsoluteCountFields({
key="select"
value={segment.operator}
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value="more">{MailPoet.I18n.t('moreThan')}</option>
@ -76,7 +76,7 @@ export function EmailOpensAbsoluteCountFields({
value={segment.opens || ''}
data-automation-id="segment-number-of-opens"
onChange={(e) => {
updateSegmentFilterFromEvent('opens', filterIndex, e);
void updateSegmentFilterFromEvent('opens', filterIndex, e);
}}
min="0"
placeholder={MailPoet.I18n.t('emailActionOpens')}
@ -99,7 +99,7 @@ export function EmailOpensAbsoluteCountFields({
value={segment.days || ''}
data-automation-id="segment-number-of-days"
onChange={(e) => {
updateSegmentFilterFromEvent('days', filterIndex, e);
void updateSegmentFilterFromEvent('days', filterIndex, e);
}}
min="0"
placeholder={MailPoet.I18n.t('emailActionDays')}

View File

@ -93,7 +93,7 @@ export function EmailClickStatisticsFields({
segment.operator !== AnyValueTypes.ALL &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [segment.operator, filterIndex, updateSegmentFilter]);
@ -108,7 +108,7 @@ export function EmailClickStatisticsFields({
options={newsletterOptions}
value={find(['value', segment.newsletter_id], newsletterOptions)}
onChange={(option: SelectOption): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ newsletter_id: option.value, link_ids: [] },
filterIndex,
);
@ -158,7 +158,7 @@ export function EmailClickStatisticsFields({
return segment.link_ids.indexOf(option.value) !== -1;
}, links)}
onChange={(options: SelectOption[]): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ link_ids: (options || []).map((x) => x.value) },
filterIndex,
);

View File

@ -51,14 +51,14 @@ export function EmailOpenStatisticsFields({ filterIndex }: Props): JSX.Element {
segment.operator !== AnyValueTypes.ALL &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
// None is not allowed for Machine Opened
if (
segment.action === EmailActionTypes.MACHINE_OPENED &&
segment.operator === AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [segment.action, segment.operator, filterIndex, updateSegmentFilter]);
@ -70,7 +70,7 @@ export function EmailOpenStatisticsFields({ filterIndex }: Props): JSX.Element {
isFullWidth
value={segment.operator}
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value={AnyValueTypes.ANY}>{MailPoet.I18n.t('anyOf')}</option>
@ -96,7 +96,7 @@ export function EmailOpenStatisticsFields({ filterIndex }: Props): JSX.Element {
return segment.newsletters.indexOf(newsletterId) !== -1;
}, newsletterOptions)}
onChange={(options: SelectOption[]): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ newsletters: map('value', options) },
filterIndex,
);

View File

@ -99,7 +99,7 @@ export function MailPoetCustomFields({ filterIndex }: Props): JSX.Element {
customFieldsList,
);
if (!customField) return;
updateSegmentFilter(
void updateSegmentFilter(
{
custom_field_id: option.value,
custom_field_type: customField.type,

View File

@ -80,7 +80,7 @@ export function SubscriberScoreFields({ filterIndex }: Props): JSX.Element {
if (
!availableOperators.includes(segment.operator as SubscriberScoreOperator)
) {
updateSegmentFilter(
void updateSegmentFilter(
{ operator: SubscriberScoreOperator.HIGHER_THAN },
filterIndex,
);
@ -92,13 +92,13 @@ export function SubscriberScoreFields({ filterIndex }: Props): JSX.Element {
segment.operator === SubscriberScoreOperator.NOT_EQUALS) &&
typeof segment.value === 'undefined'
) {
updateSegmentFilter({ value: '' }, filterIndex);
void updateSegmentFilter({ value: '' }, filterIndex);
}
if (
segment.operator === SubscriberScoreOperator.UNKNOWN ||
segment.operator === SubscriberScoreOperator.NOT_UNKNOWN
) {
updateSegmentFilter({ value: null }, filterIndex);
void updateSegmentFilter({ value: null }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -112,7 +112,7 @@ export function SubscriberScoreFields({ filterIndex }: Props): JSX.Element {
value={segment.operator}
automationId="segment-subscriber-score-operator"
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value={SubscriberScoreOperator.HIGHER_THAN}>
@ -148,7 +148,7 @@ export function SubscriberScoreFields({ filterIndex }: Props): JSX.Element {
value={segment.value || ''}
data-automation-id="segment-subscriber-score-value"
onChange={(e) => {
updateSegmentFilterFromEvent('value', filterIndex, e);
void updateSegmentFilterFromEvent('value', filterIndex, e);
}}
min="0"
placeholder={MailPoet.I18n.t('subscriberScorePlaceholder')}

View File

@ -67,7 +67,7 @@ export function SubscribedDateFields({ filterIndex }: Props): JSX.Element {
if (
!availableOperators.includes(segment.operator as SubscribedDateOperator)
) {
updateSegmentFilter(
void updateSegmentFilter(
{ operator: SubscribedDateOperator.BEFORE },
filterIndex,
);
@ -80,7 +80,7 @@ export function SubscribedDateFields({ filterIndex }: Props): JSX.Element {
(parseDate(segment.value) === undefined ||
!/^\d+-\d+-\d+$/.test(segment.value))
) {
updateSegmentFilter(
void updateSegmentFilter(
{ value: convertDateToString(new Date()) },
filterIndex,
);
@ -91,7 +91,7 @@ export function SubscribedDateFields({ filterIndex }: Props): JSX.Element {
typeof segment.value === 'string' &&
!/^\d*$/.exec(segment.value)
) {
updateSegmentFilter({ value: '' }, filterIndex);
void updateSegmentFilter({ value: '' }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -101,7 +101,7 @@ export function SubscribedDateFields({ filterIndex }: Props): JSX.Element {
key="select"
value={segment.operator}
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value={SubscribedDateOperator.BEFORE}>
@ -130,7 +130,7 @@ export function SubscribedDateFields({ filterIndex }: Props): JSX.Element {
<Datepicker
dateFormat="MMM d, yyyy"
onChange={(value): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ value: convertDateToString(value) },
filterIndex,
);
@ -146,7 +146,7 @@ export function SubscribedDateFields({ filterIndex }: Props): JSX.Element {
type="number"
value={segment.value}
onChange={(e) => {
updateSegmentFilterFromEvent('value', filterIndex, e);
void updateSegmentFilterFromEvent('value', filterIndex, e);
}}
min="1"
placeholder={MailPoet.I18n.t('daysPlaceholder')}

View File

@ -52,7 +52,7 @@ export function SubscribedToList({ filterIndex }: Props): JSX.Element {
segment.operator !== AnyValueTypes.ALL &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
const options = staticSegmentsList.map((currentValue) => ({
@ -68,7 +68,7 @@ export function SubscribedToList({ filterIndex }: Props): JSX.Element {
isFullWidth
value={segment.operator}
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value={AnyValueTypes.ANY}>{MailPoet.I18n.t('anyOf')}</option>
@ -91,7 +91,7 @@ export function SubscribedToList({ filterIndex }: Props): JSX.Element {
return segment.segments.indexOf(segmentId) !== -1;
}, options)}
onChange={(selectOptions: SelectOption[]): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ segments: map('value', selectOptions) },
filterIndex,
);

View File

@ -37,7 +37,7 @@ export function WordpressRoleFields({ filterIndex }: Props): JSX.Element {
segment.operator !== AnyValueTypes.ALL &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -58,7 +58,7 @@ export function WordpressRoleFields({ filterIndex }: Props): JSX.Element {
isFullWidth
value={segment.operator}
onChange={(e) => {
updateSegmentFilterFromEvent('operator', filterIndex, e);
void updateSegmentFilterFromEvent('operator', filterIndex, e);
}}
>
<option value={AnyValueTypes.ANY}>{MailPoet.I18n.t('anyOf')}</option>
@ -81,7 +81,7 @@ export function WordpressRoleFields({ filterIndex }: Props): JSX.Element {
return segment.wordpressRole.indexOf(option.value) !== -1;
}, options)}
onChange={(selectOptions: SelectOption[]): void => {
updateSegmentFilter(
void updateSegmentFilter(
{ wordpressRole: map('value', selectOptions) },
filterIndex,
);

View File

@ -170,13 +170,13 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
segment.number_of_orders_type === undefined &&
segment.action === WooCommerceActionTypes.NUMBER_OF_ORDERS
) {
updateSegmentFilter({ number_of_orders_type: '=' }, filterIndex);
void updateSegmentFilter({ number_of_orders_type: '=' }, filterIndex);
}
if (
segment.total_spent_type === undefined &&
segment.action === WooCommerceActionTypes.TOTAL_SPENT
) {
updateSegmentFilter({ total_spent_type: '>' }, filterIndex);
void updateSegmentFilter({ total_spent_type: '>' }, filterIndex);
}
if (
actionTypesWithDefaultTypeAny.includes(segment.action) &&
@ -184,14 +184,14 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
segment.operator !== AnyValueTypes.ANY &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
if (
segment.action === WooCommerceActionTypes.CUSTOMER_IN_COUNTRY &&
segment.operator !== AnyValueTypes.ANY &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -202,9 +202,12 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
<Select
key="select-operator"
value={segment.operator}
onChange={(e): void =>
updateSegmentFilter({ operator: e.target.value }, filterIndex)
}
onChange={(e): void => {
void updateSegmentFilter(
{ operator: e.target.value },
filterIndex,
);
}}
automationId="select-operator"
>
<option value={AnyValueTypes.ANY}>
@ -235,16 +238,16 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
}
return segment.product_ids.indexOf(productOption.value) !== -1;
}, productOptions)}
onChange={(options: SelectOption[]): void =>
updateSegmentFilter(
onChange={(options: SelectOption[]): void => {
void updateSegmentFilter(
{
product_ids: (options || []).map(
(x: SelectOption) => x.value,
),
},
filterIndex,
)
}
);
}}
automationId="select-segment-products"
/>
</Grid.CenteredRow>
@ -257,9 +260,12 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
<Select
key="select-operator"
value={segment.operator}
onChange={(e): void =>
updateSegmentFilter({ operator: e.target.value }, filterIndex)
}
onChange={(e): void => {
void updateSegmentFilter(
{ operator: e.target.value },
filterIndex,
);
}}
automationId="select-operator"
>
<option value={AnyValueTypes.ANY}>
@ -290,16 +296,16 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
}
return segment.category_ids.indexOf(categoryOption.value) !== -1;
}, categoryOptions)}
onChange={(options: SelectOption[]): void =>
updateSegmentFilter(
onChange={(options: SelectOption[]): void => {
void updateSegmentFilter(
{
category_ids: (options || []).map(
(x: SelectOption) => x.value,
),
},
filterIndex,
)
}
);
}}
automationId="select-segment-category"
/>
</Grid.CenteredRow>
@ -313,7 +319,7 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
key="select"
value={segment.number_of_orders_type}
onChange={(e): void => {
updateSegmentFilterFromEvent(
void updateSegmentFilterFromEvent(
'number_of_orders_type',
filterIndex,
e,
@ -333,7 +339,7 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
value={segment.number_of_orders_count || ''}
placeholder={MailPoet.I18n.t('wooNumberOfOrdersCount')}
onChange={(e): void => {
updateSegmentFilterFromEvent(
void updateSegmentFilterFromEvent(
'number_of_orders_count',
filterIndex,
e,
@ -351,7 +357,7 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
value={segment.number_of_orders_days || ''}
placeholder={MailPoet.I18n.t('daysPlaceholder')}
onChange={(e): void => {
updateSegmentFilterFromEvent(
void updateSegmentFilterFromEvent(
'number_of_orders_days',
filterIndex,
e,
@ -370,7 +376,11 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
key="select"
value={segment.total_spent_type}
onChange={(e): void => {
updateSegmentFilterFromEvent('total_spent_type', filterIndex, e);
void updateSegmentFilterFromEvent(
'total_spent_type',
filterIndex,
e,
);
}}
automationId="select-total-spent-type"
>
@ -387,7 +397,7 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
value={segment.total_spent_amount || ''}
placeholder={MailPoet.I18n.t('wooTotalSpentAmount')}
onChange={(e): void => {
updateSegmentFilterFromEvent(
void updateSegmentFilterFromEvent(
'total_spent_amount',
filterIndex,
e,
@ -405,7 +415,11 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
value={segment.total_spent_days || ''}
placeholder={MailPoet.I18n.t('daysPlaceholder')}
onChange={(e): void => {
updateSegmentFilterFromEvent('total_spent_days', filterIndex, e);
void updateSegmentFilterFromEvent(
'total_spent_days',
filterIndex,
e,
);
}}
/>
<div>{MailPoet.I18n.t('days')}</div>
@ -419,9 +433,12 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
<Select
key="select-operator-country"
value={segment.operator}
onChange={(e): void =>
updateSegmentFilter({ operator: e.target.value }, filterIndex)
}
onChange={(e): void => {
void updateSegmentFilter(
{ operator: e.target.value },
filterIndex,
);
}}
automationId="select-operator-country"
>
<option value={AnyValueTypes.ANY}>
@ -444,16 +461,16 @@ export const WooCommerceFields: FunctionComponent<Props> = ({
if (!segment.country_code) return undefined;
return segment.country_code.indexOf(option.value) !== -1;
}, countryOptions)}
onChange={(options: SelectOption[]): void =>
updateSegmentFilter(
onChange={(options: SelectOption[]): void => {
void updateSegmentFilter(
{
country_code: (options || []).map(
(x: SelectOption) => x.value,
),
},
filterIndex,
)
}
);
}}
automationId="select-segment-country"
/>
</Grid.CenteredRow>

View File

@ -74,7 +74,7 @@ export function WooCommerceMembershipFields({
segment.operator !== AnyValueTypes.ALL &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -108,12 +108,12 @@ export function WooCommerceMembershipFields({
if (!segment.plan_ids) return false;
return segment.plan_ids.indexOf(option.value) !== -1;
}, planOptions)}
onChange={(options: SelectOption[]): void =>
updateSegmentFilter(
onChange={(options: SelectOption[]): void => {
void updateSegmentFilter(
{ plan_ids: (options || []).map((x: SelectOption) => x.value) },
filterIndex,
)
}
);
}}
automationId="select-segment-plans"
/>
</Grid.CenteredRow>

View File

@ -77,7 +77,7 @@ export function WooCommerceSubscriptionFields({
segment.operator !== AnyValueTypes.ALL &&
segment.operator !== AnyValueTypes.NONE
) {
updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
void updateSegmentFilter({ operator: AnyValueTypes.ANY }, filterIndex);
}
}, [updateSegmentFilter, segment, filterIndex]);
@ -111,14 +111,14 @@ export function WooCommerceSubscriptionFields({
if (!segment.product_ids) return false;
return segment.product_ids.indexOf(option.value) !== -1;
}, productOptions)}
onChange={(options: SelectOption[]): void =>
updateSegmentFilter(
onChange={(options: SelectOption[]): void => {
void updateSegmentFilter(
{
product_ids: (options || []).map((x: SelectOption) => x.value),
},
filterIndex,
)
}
);
}}
automationId="select-segment-products"
/>
</Grid.CenteredRow>

View File

@ -18,7 +18,7 @@ export function Editor(): JSX.Element {
const { pageLoaded } = useDispatch('mailpoet-dynamic-segments-form');
useEffect(() => {
pageLoaded(match.params.id);
void pageLoaded(match.params.id);
}, [match.params.id, pageLoaded]);
return (

View File

@ -101,7 +101,9 @@ export function Form({ segmentId }: Props): JSX.Element {
name="name"
id="field_name"
defaultValue={segment.name}
onChange={(e): void => updateSegment({ name: e.target.value })}
onChange={(e): void => {
void updateSegment({ name: e.target.value });
}}
/>
</div>
</div>
@ -120,9 +122,9 @@ export function Form({ segmentId }: Props): JSX.Element {
name="description"
id="field_description"
value={segment.description}
onChange={(e): void =>
updateSegment({ description: e.target.value })
}
onChange={(e): void => {
void updateSegment({ description: e.target.value });
}}
/>
</div>
</div>
@ -148,7 +150,7 @@ export function Form({ segmentId }: Props): JSX.Element {
options={segmentFilters}
value={filterRow.filterValue}
onChange={(newValue: FilterValue): void => {
updateSegmentFilter(
void updateSegmentFilter(
{
segmentType: newValue.group,
action: newValue.value,
@ -193,7 +195,7 @@ export function Form({ segmentId }: Props): JSX.Element {
type="submit"
onClick={(e): void => {
e.preventDefault();
handleSave(segmentId);
void handleSave(segmentId);
}}
isDisabled={
!isFormValid(segment.filters) ||

View File

@ -57,7 +57,7 @@ function SubscribersCounter(): JSX.Element {
finished.count = response.count;
finished.errors = response.errors;
}
updateSubscriberCount(finished);
void updateSubscriberCount(finished);
},
(errorResponse) => {
isRequestInFlight.current = false;
@ -66,7 +66,7 @@ function SubscribersCounter(): JSX.Element {
finished.loading = false;
finished.count = undefined;
finished.errors = errors;
updateSubscriberCount(finished);
void updateSubscriberCount(finished);
},
);
}
@ -75,7 +75,7 @@ function SubscribersCounter(): JSX.Element {
useEffect(() => {
if (isFormValid(segment.filters)) {
updateSubscriberCount({
void updateSubscriberCount({
loading: true,
count: undefined,
errors: undefined,
@ -83,7 +83,7 @@ function SubscribersCounter(): JSX.Element {
const debouncedLoad = debouncedLoadRef.current;
debouncedLoad(segment);
} else {
updateSubscriberCount({
void updateSubscriberCount({
count: undefined,
loading: false,
});