Updated support email error messages (#20558)

Fixes
https://linear.app/tryghost/issue/DES-537/inconsistent-error-messages-for-invalid-email

We were showing inconsistent error messages when changing the support
email address in Portal settings. They are now consistently shown
inline, rather than in a toast.
This commit is contained in:
Daniël van der Winden 2024-07-08 16:16:38 +02:00 committed by GitHub
parent a6c6114e6f
commit dfb0f93c06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import React, {FocusEventHandler, useEffect, useState} from 'react';
import validator from 'validator';
import {Form, TextField} from '@tryghost/admin-x-design-system';
import {SettingValue, getSettingValues} from '@tryghost/admin-x-framework/api/settings';
import {fullEmailAddress, getEmailDomain} from '@tryghost/admin-x-framework/api/site';
@ -19,8 +20,9 @@ const AccountPage: React.FC<{
let supportAddress = e.target.value;
if (!supportAddress) {
setError('members_support_address', 'Please enter an email address');
return;
setError('members_support_address', 'Enter an email address');
} else if (!validator.isEmail(supportAddress)) {
setError('members_support_address', 'Enter a valid email address');
} else {
setError('members_support_address', '');
}