Set initial sending method
[MAILPOET-2693]
This commit is contained in:
committed by
Veljko V
parent
75ec035cec
commit
4312dd3532
@@ -6,22 +6,21 @@ import { useSetting } from 'settings/store/hooks';
|
||||
export default function SendingMethod() {
|
||||
const [provider, setProvider] = useSetting('smtp_provider');
|
||||
const [, setMethod] = useSetting('mta', 'method');
|
||||
const updateProvider = (value: 'server' | 'manual' | 'AmazonSES' | 'SendGrid') => {
|
||||
setProvider(value);
|
||||
switch (value) {
|
||||
React.useEffect(() => {
|
||||
switch (provider) {
|
||||
case 'server': setMethod('PHPMail'); break;
|
||||
case 'manual': setMethod('SMTP'); break;
|
||||
case 'AmazonSES': setMethod('AmazonSES'); break;
|
||||
case 'SendGrid': setMethod('AmazonSES'); break;
|
||||
default:
|
||||
default: setMethod('PHPMail');
|
||||
}
|
||||
};
|
||||
}, [provider, setMethod]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Label title={t('method')} htmlFor="mailpoet_smtp_method" />
|
||||
<Inputs>
|
||||
<select id="mailpoet_smtp_method" value={provider} onChange={onChange(updateProvider)}>
|
||||
<select id="mailpoet_smtp_method" value={provider} onChange={onChange(setProvider)}>
|
||||
<option value="server">{t('hostOption')}</option>
|
||||
<option value="manual">{t('smtpOption')}</option>
|
||||
<optgroup label={t('selectProvider')}>
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import React from 'react';
|
||||
import { Settings } from '../types';
|
||||
import useSelector from './useSelector';
|
||||
import { ValueAndSetter } from './types';
|
||||
@@ -26,6 +27,6 @@ export function useSetting(...path: string[]): [any, (value: any) => any] {
|
||||
const setValue = useAction('setSetting');
|
||||
return [
|
||||
getValue(path),
|
||||
(value) => setValue(path, value),
|
||||
React.useCallback((value) => setValue(path, value), path), // eslint-disable-line
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user