Move utility functions to common functions

[MAILPOET-2677]
This commit is contained in:
Amine Ben hammou
2020-03-18 16:45:31 +01:00
committed by Veljko V
parent 50ca3b7310
commit dc0fc44194
16 changed files with 19 additions and 18 deletions

View File

@@ -0,0 +1,8 @@
import { ChangeEvent } from 'react';
type Setter = (value: string) => any
type Event = ChangeEvent<any>
export const onChange = (setter: Setter) => (e: Event) => setter(e.target.value);
export const onToggle = (setter: Setter) => (e: Event) => setter(e.target.checked ? '1' : '0');

View File

@@ -0,0 +1,3 @@
export * from './change_handlers';
export { default as t } from './t';
export { default as isEmail } from './is_email';

View File

@@ -0,0 +1 @@
export default (value: string): boolean => (window as any).mailpoet_email_regex.test(value);

View File

@@ -0,0 +1,3 @@
import MailPoet from 'mailpoet';
export default ([word]: TemplateStringsArray) => MailPoet.I18n.t(word);