Add utils functions
[MAILPOET-2677]
This commit is contained in:
committed by
Veljko V
parent
6cdb029465
commit
ecffd118af
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MailPoet from 'mailpoet';
|
import { t, onChange } from 'settings/utils';
|
||||||
import { Label, Inputs } from 'settings/components';
|
import { Label, Inputs } from 'settings/components';
|
||||||
import { useSetting, useSelector } from 'settings/store/hooks';
|
import { useSetting, useSelector } from 'settings/store/hooks';
|
||||||
import SenderEmailAddressWarning from 'common/sender_email_address_warning.jsx';
|
import SenderEmailAddressWarning from 'common/sender_email_address_warning.jsx';
|
||||||
@@ -13,26 +13,26 @@ export default function DefaultSender() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Label
|
<Label
|
||||||
title={MailPoet.I18n.t('defaultSenderTitle')}
|
title={t`defaultSenderTitle`}
|
||||||
description={MailPoet.I18n.t('defaultSenderDescription')}
|
description={t`defaultSenderDescription`}
|
||||||
htmlFor="sender-name"
|
htmlFor="sender-name"
|
||||||
/>
|
/>
|
||||||
<Inputs>
|
<Inputs>
|
||||||
<label htmlFor="sender-name">{MailPoet.I18n.t('from')}</label>
|
<label htmlFor="sender-name">{t`from`}</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="sender-name"
|
id="sender-name"
|
||||||
placeholder={MailPoet.I18n.t('yourName')}
|
placeholder={t`yourName`}
|
||||||
data-automation-id="settings-page-from-name-field"
|
data-automation-id="settings-page-from-name-field"
|
||||||
value={senderName}
|
value={senderName}
|
||||||
onChange={(event) => setSenderName(event.target.value)}
|
onChange={onChange(setSenderName)}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="from@mydomain.com"
|
placeholder="from@mydomain.com"
|
||||||
data-automation-id="settings-page-from-email-field"
|
data-automation-id="settings-page-from-email-field"
|
||||||
value={senderEmail}
|
value={senderEmail}
|
||||||
onChange={(event) => setSenderEmail(event.target.value)}
|
onChange={onChange(setSenderEmail)}
|
||||||
/>
|
/>
|
||||||
<div className="regular-text">
|
<div className="regular-text">
|
||||||
<SenderEmailAddressWarning
|
<SenderEmailAddressWarning
|
||||||
@@ -44,17 +44,17 @@ export default function DefaultSender() {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="reply_to-name"
|
id="reply_to-name"
|
||||||
placeholder={MailPoet.I18n.t('yourName')}
|
placeholder={t`yourName`}
|
||||||
data-automation-id="settings-page-from-name-field"
|
data-automation-id="settings-page-from-name-field"
|
||||||
value={replyToName}
|
value={replyToName}
|
||||||
onChange={(event) => setReplyToName(event.target.value)}
|
onChange={onChange(setReplyToName)}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="reply_to@mydomain.com"
|
placeholder="reply_to@mydomain.com"
|
||||||
data-automation-id="settings-page-from-email-field"
|
data-automation-id="settings-page-from-email-field"
|
||||||
value={replyToEmail}
|
value={replyToEmail}
|
||||||
onChange={(event) => setReplyToEmail(event.target.value)}
|
onChange={onChange(setReplyToEmail)}
|
||||||
/>
|
/>
|
||||||
</Inputs>
|
</Inputs>
|
||||||
</>
|
</>
|
||||||
|
8
assets/js/src/settings/utils.ts
Normal file
8
assets/js/src/settings/utils.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
import { ChangeEvent } from 'react';
|
||||||
|
|
||||||
|
type Setter = (value: string) => any
|
||||||
|
type Event = ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
||||||
|
export const onChange = (setter: Setter) => (e: Event) => setter(e.target.value);
|
||||||
|
|
||||||
|
export const t = ([word]: TemplateStringsArray) => MailPoet.I18n.t(word);
|
Reference in New Issue
Block a user