feat(settings): review custom domain (#10393)
Introduce improved validation logic for custom domains, including regex validation with descriptive error messages. Implement asynchronous domain update functionality with a loading indicator and polling to check record statuses. Refactor components to streamline functionality and align with updated state management. Fix https://github.com/twentyhq/core-team-issues/issues/453
This commit is contained in:
@ -81,8 +81,6 @@ export class CustomDomainService {
|
||||
]
|
||||
.map<CustomDomainValidRecords['records'][0] | undefined>(
|
||||
(record: Record<string, string>) => {
|
||||
if (!record) return;
|
||||
|
||||
if (
|
||||
'txt_name' in record &&
|
||||
'txt_value' in record &&
|
||||
@ -92,7 +90,11 @@ export class CustomDomainService {
|
||||
return {
|
||||
validationType: 'ssl' as const,
|
||||
type: 'txt' as const,
|
||||
status: response.result[0].ssl.status ?? 'pending',
|
||||
status:
|
||||
!response.result[0].ssl.status ||
|
||||
response.result[0].ssl.status.startsWith('pending')
|
||||
? 'pending'
|
||||
: response.result[0].ssl.status,
|
||||
key: record.txt_name,
|
||||
value: record.txt_value,
|
||||
};
|
||||
@ -120,10 +122,16 @@ export class CustomDomainService {
|
||||
validationType: 'redirection' as const,
|
||||
type: 'cname' as const,
|
||||
status:
|
||||
response.result[0].verification_errors?.[0] ===
|
||||
'custom hostname does not CNAME to this zone.'
|
||||
? 'error'
|
||||
: 'success',
|
||||
// wait 10s before starting the real check
|
||||
response.result[0].created_at &&
|
||||
new Date().getTime() -
|
||||
new Date(response.result[0].created_at).getTime() <
|
||||
1000 * 10
|
||||
? 'pending'
|
||||
: response.result[0].verification_errors?.[0] ===
|
||||
'custom hostname does not CNAME to this zone.'
|
||||
? 'error'
|
||||
: 'success',
|
||||
key: response.result[0].hostname,
|
||||
value: this.domainManagerService.getFrontUrl().hostname,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user