|
|
@@ -15,6 +15,9 @@ import { useHistory } from 'react-router-dom';
|
|
|
import Spinner from '../../Spinner/Spinner';
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
import { Helmet } from 'react-helmet';
|
|
|
+import { checkAuthHandler } from 'src/actions/Session/sessionActions';
|
|
|
+import { refreshCounters } from 'src/actions/MenuCounters/menuCounterActions';
|
|
|
+import HtmlParser from 'react-html-parser';
|
|
|
|
|
|
export default function EditMailAccount(props) {
|
|
|
const [autoreplyChecked, setAutoreplyChecked] = useState(false);
|
|
|
@@ -56,13 +59,14 @@ export default function EditMailAccount(props) {
|
|
|
editMailAccount(newMailDomain, props.domain, props.account)
|
|
|
.then(result => {
|
|
|
if (result.status === 200) {
|
|
|
- const { error_msg, ok_msg } = result.data;
|
|
|
-
|
|
|
- if (error_msg) {
|
|
|
- setState({ ...state, errorMessage: error_msg, okMessage: '', loading: false });
|
|
|
- } else if (ok_msg) {
|
|
|
- goBack();
|
|
|
- setState({ ...state, errorMessage: '', okMessage: ok_msg, loading: false });
|
|
|
+ const { error_msg: errorMessage, ok_msg: okMessage } = result.data;
|
|
|
+
|
|
|
+ if (errorMessage) {
|
|
|
+ setState({ ...state, errorMessage, okMessage, loading: false });
|
|
|
+ } else {
|
|
|
+ dispatch(refreshCounters()).then(() => {
|
|
|
+ setState({ ...state, okMessage, errorMessage: '', loading: false });
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -88,12 +92,9 @@ export default function EditMailAccount(props) {
|
|
|
.catch(err => console.error(err));
|
|
|
}
|
|
|
|
|
|
- const toggleQuotaValue = () => {
|
|
|
- if (state.quotaValue !== 'unlimited') {
|
|
|
- setState({ ...state, quotaValue: 'unlimited' });
|
|
|
- } else {
|
|
|
- setState({ ...state, quotaValue: '' });
|
|
|
- }
|
|
|
+ const toggleQuota = () => {
|
|
|
+ const value = state.data.quota === 'unlimited' ? '1000' : 'unlimited';
|
|
|
+ setState({ ...state, data: { ...state.data, quota: value } });
|
|
|
}
|
|
|
|
|
|
const goBack = () => {
|
|
|
@@ -116,7 +117,7 @@ export default function EditMailAccount(props) {
|
|
|
<div className="success">
|
|
|
<span className="ok-message">
|
|
|
{state.okMessage ? <FontAwesomeIcon icon="long-arrow-alt-right" /> : ''}
|
|
|
- <span dangerouslySetInnerHTML={{ __html: state.okMessage }}></span>
|
|
|
+ <span>{HtmlParser(state.okMessage)}</span>
|
|
|
</span>
|
|
|
</div>
|
|
|
</Toolbar>
|
|
|
@@ -135,13 +136,58 @@ export default function EditMailAccount(props) {
|
|
|
id="domain"
|
|
|
disabled />
|
|
|
|
|
|
- <TextInput
|
|
|
- title={i18n['Account']}
|
|
|
- value={props.account}
|
|
|
- name="v_account"
|
|
|
- id="account" />
|
|
|
-
|
|
|
<Password name="v_password" onChange={password => setState({ ...state, password })} />
|
|
|
+
|
|
|
+ <TextInputWithExtraButton title={i18n['Quota']} optionalTitle={i18n['in megabytes']} id="quota" name="v_quota" value={state.data.quota}>
|
|
|
+ <button type="button" onClick={toggleQuota}>
|
|
|
+ <FontAwesomeIcon icon="infinity" />
|
|
|
+ </button>
|
|
|
+ </TextInputWithExtraButton>
|
|
|
+
|
|
|
+ <TextArea
|
|
|
+ optionalTitle={`${i18n['use local-part']}`}
|
|
|
+ defaultValue={state.data.aliases}
|
|
|
+ title={i18n['Aliases']}
|
|
|
+ name="v_aliases"
|
|
|
+ id="aliases" />
|
|
|
+
|
|
|
+ <TextArea
|
|
|
+ optionalTitle={`${i18n['one or more email addresses']}`}
|
|
|
+ defaultValue={state.data.fwd}
|
|
|
+ title={i18n['Forward to']}
|
|
|
+ name="v_fwd"
|
|
|
+ id="fwd" />
|
|
|
+
|
|
|
+ <Checkbox
|
|
|
+ title={i18n['Do not store forwarded mail']}
|
|
|
+ defaultChecked={state.data.fwd_only === 'yes'}
|
|
|
+ name="v_fwd_only"
|
|
|
+ id="fwd_only" />
|
|
|
+
|
|
|
+ <Checkbox
|
|
|
+ title={i18n['Autoreply']}
|
|
|
+ checked={autoreplyChecked}
|
|
|
+ onChange={checked => setAutoreplyChecked(checked)}
|
|
|
+ name="v_autoreply"
|
|
|
+ id="autoreply" />
|
|
|
+
|
|
|
+ {
|
|
|
+ autoreplyChecked && (
|
|
|
+ <div style={{ transform: 'translateX(3rem)' }}>
|
|
|
+ <TextArea
|
|
|
+ defaultValue={state.data.autoreply_message}
|
|
|
+ title={i18n['Message']}
|
|
|
+ name="v_autoreply_message"
|
|
|
+ id="autoreply_message" />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ <TextInput
|
|
|
+ title={i18n['Send login credentials to email address']}
|
|
|
+ value={state.data.send_email}
|
|
|
+ name="v_credentials"
|
|
|
+ id="credentials" />
|
|
|
</div>
|
|
|
|
|
|
<div className="c-2">
|
|
|
@@ -153,59 +199,6 @@ export default function EditMailAccount(props) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div className="r-2">
|
|
|
- <TextInputWithExtraButton title={i18n['Quota']} optionalTitle={i18n['in megabytes']} id="quota" name="v_quota" value={state.data.quota}>
|
|
|
- <button type="button" onClick={toggleQuotaValue}>
|
|
|
- <FontAwesomeIcon icon="infinity" />
|
|
|
- </button>
|
|
|
- </TextInputWithExtraButton>
|
|
|
-
|
|
|
- <TextArea
|
|
|
- optionalTitle={`${i18n['use local-part']}`}
|
|
|
- defaultValue={state.data.aliases}
|
|
|
- title={i18n['Aliases']}
|
|
|
- name="v_aliases"
|
|
|
- id="aliases" />
|
|
|
-
|
|
|
- <TextArea
|
|
|
- optionalTitle={`${i18n['one or more email addresses']}`}
|
|
|
- defaultValue={state.data.fwd}
|
|
|
- title={i18n['Forward to']}
|
|
|
- name="v_fwd"
|
|
|
- id="fwd" />
|
|
|
-
|
|
|
- <Checkbox
|
|
|
- title={i18n['Do not store forwarded mail']}
|
|
|
- defaultChecked={state.data.fwd_only === 'yes'}
|
|
|
- name="v_fwd_only"
|
|
|
- id="fwd_only" />
|
|
|
-
|
|
|
- <Checkbox
|
|
|
- title={i18n['Autoreply']}
|
|
|
- checked={autoreplyChecked}
|
|
|
- onChange={checked => setAutoreplyChecked(checked)}
|
|
|
- name="v_fwd_only"
|
|
|
- id="fwd_only" />
|
|
|
-
|
|
|
- {
|
|
|
- autoreplyChecked && (
|
|
|
- <div style={{ transform: 'translateX(3rem)' }}>
|
|
|
- <TextArea
|
|
|
- defaultValue={state.data.autoreply_message}
|
|
|
- title={i18n['Message']}
|
|
|
- name="v_autoreply_message"
|
|
|
- id="autoreply_message" />
|
|
|
- </div>
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- <TextInput
|
|
|
- title={i18n['Send login credentials to email address']}
|
|
|
- value={state.data.send_email}
|
|
|
- name="v_credentials"
|
|
|
- id="credentials" />
|
|
|
- </div>
|
|
|
-
|
|
|
<div className="buttons-wrapper">
|
|
|
<button type="submit" className="add">{i18n.Add}</button>
|
|
|
<button type="button" className="back" onClick={goBack}>{i18n.Back}</button>
|