mirror of https://github.com/buster-so/buster.git
Update apps/web/src/components/features/security/ApprovedEmailDomains.tsx
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
parent
26d77fef53
commit
aa22c9f378
|
@ -89,8 +89,14 @@ const AddDomainInput = React.memo(
|
||||||
const [newDomain, setNewDomain] = useState('');
|
const [newDomain, setNewDomain] = useState('');
|
||||||
|
|
||||||
const handleAddDomain = useMemoizedFn(async () => {
|
const handleAddDomain = useMemoizedFn(async () => {
|
||||||
if (!newDomain.trim()) return;
|
const domain = newDomain.trim();
|
||||||
|
if (!domain) return;
|
||||||
|
|
||||||
|
const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]\.[a-zA-Z]{2,}$/;
|
||||||
|
if (!domainRegex.test(domain)) {
|
||||||
|
openErrorMessage('Please enter a valid domain name');
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await addDomain({ domains: [newDomain.trim()] });
|
await addDomain({ domains: [newDomain.trim()] });
|
||||||
setNewDomain('');
|
setNewDomain('');
|
||||||
|
|
Loading…
Reference in New Issue