diff --git a/assets/js/src/newsletter_editor/initializer.jsx b/assets/js/src/newsletter_editor/initializer.jsx index 33b83d2605..a15c3a8ab0 100644 --- a/assets/js/src/newsletter_editor/initializer.jsx +++ b/assets/js/src/newsletter_editor/initializer.jsx @@ -2,7 +2,7 @@ import Hooks from 'wp-js-hooks'; import MailPoet from 'mailpoet'; import React from 'react'; import ReactDOM from 'react-dom'; -import ListingHeadingSteps from 'newsletters/listings/heading_steps.jsx'; +import ListingHeadingSteps from 'newsletters/listings/heading_steps'; import fetchAutomaticEmailShortcodes from 'newsletters/automatic_emails/fetch_editor_shortcodes.jsx'; import displayTutorial from './tutorial.jsx'; diff --git a/assets/js/src/newsletters/listings/heading_display.jsx b/assets/js/src/newsletters/listings/heading_display.jsx index b19a532642..0ecdaeacb5 100644 --- a/assets/js/src/newsletters/listings/heading_display.jsx +++ b/assets/js/src/newsletters/listings/heading_display.jsx @@ -1,5 +1,5 @@ import { withRouter } from 'react-router-dom'; -import { mapPathToSteps } from './heading_steps.jsx'; +import { mapPathToSteps } from './heading_steps.tsx'; const isHeaderHidden = (location) => location.hash.match(new RegExp('^#/new')) || location.pathname.match(new RegExp('^/new')); diff --git a/assets/js/src/newsletters/listings/heading_steps.jsx b/assets/js/src/newsletters/listings/heading_steps.tsx similarity index 73% rename from assets/js/src/newsletters/listings/heading_steps.jsx rename to assets/js/src/newsletters/listings/heading_steps.tsx index e350d25189..701a411884 100644 --- a/assets/js/src/newsletters/listings/heading_steps.jsx +++ b/assets/js/src/newsletters/listings/heading_steps.tsx @@ -1,23 +1,23 @@ import React from 'react'; import MailPoet from 'mailpoet'; -import HideScreenOptions from '../../common/hide_screen_options/hide_screen_options.tsx'; -import Steps from '../../common/steps/steps.tsx'; +import HideScreenOptions from '../../common/hide_screen_options/hide_screen_options'; +import Steps from '../../common/steps/steps'; -export const mapPathToSteps = (location) => { +export const mapPathToSteps = (location: Location): number|null => { const stepsMap = [ ['/new/.+', 1], ['/template/.+', 2], ['/send/.+', 4], ]; - if (location.search.match(/page=mailpoet-newsletter-editor/)) { + if (location.search.match(/page=mailpoet-newsletter-editor/g)) { return 3; } let stepNumber = null; stepsMap.forEach(([regex, step]) => { - if (location.hash.match(new RegExp(`^#${regex}`)) || location.pathname.match(new RegExp(`^${regex}`))) { + if ((new RegExp(`^#${regex}`)).exec(location.hash) || (new RegExp(`^${regex}`)).exec(location.pathname)) { stepNumber = step; } }); @@ -25,7 +25,7 @@ export const mapPathToSteps = (location) => { return stepNumber; }; -const getEmailTypeTitle = (emailType) => { +const getEmailTypeTitle = (emailType: string): string => { const typeMap = { standard: MailPoet.I18n.t('stepNameTypeStandard'), welcome: MailPoet.I18n.t('stepNameTypeWelcome'), @@ -36,7 +36,11 @@ const getEmailTypeTitle = (emailType) => { return typeMap[emailType] || MailPoet.I18n.t('stepNameTypeStandard'); }; -const stepsListingHeading = (step, emailTypeTitle, automationId) => ( +const stepsListingHeading = ( + step: number, + emailTypeTitle: string, + automationId: string +): JSX.Element => (