9f78580606
- Accept full domains (e.g. "example.xyz") not just labels - Check the entered TLD as primary result - Show .de, .com, .net, .org as alternative suggestions below - Primary result highlighted with accent border - Input without TLD still works (shows all 4 suggestions) - Updated i18n placeholders and added "suggestions" label Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
823 B
TypeScript
34 lines
823 B
TypeScript
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
|
|
|
|
export interface DomainCheckResult {
|
|
tld: string;
|
|
fqdn: string;
|
|
status: 'available' | 'registered';
|
|
primary: boolean;
|
|
}
|
|
|
|
export interface DomainCheckResponse {
|
|
domain: string;
|
|
results: DomainCheckResult[];
|
|
}
|
|
|
|
export async function checkDomainAction(
|
|
domain: string,
|
|
): Promise<DomainCheckResponse> {
|
|
const response = await fetch(`${API_URL}/modules/domaincheck/check`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ domain }),
|
|
credentials: 'include',
|
|
});
|
|
|
|
if (!response.ok) {
|
|
const errorBody = await response.text().catch(() => '');
|
|
throw new Error(
|
|
`Domain check failed: ${response.status} ${errorBody}`.trim(),
|
|
);
|
|
}
|
|
|
|
return response.json();
|
|
}
|