2024-07-27 01:35:00 +02:00
|
|
|
import React, {useState} from "react";
|
2024-08-23 21:19:34 +02:00
|
|
|
import {Empty, Flex, FormProps, message, Skeleton} from "antd";
|
2024-07-27 01:35:00 +02:00
|
|
|
import {Domain, getDomain} from "../../utils/api";
|
|
|
|
|
import {AxiosError} from "axios"
|
2024-07-28 15:36:22 +02:00
|
|
|
import {t} from 'ttag'
|
2024-07-29 18:41:36 +02:00
|
|
|
import {DomainSearchBar, FieldType} from "../../components/search/DomainSearchBar";
|
2024-08-20 15:22:14 +02:00
|
|
|
import {DomainResult} from "../../components/search/DomainResult";
|
2024-08-22 01:44:50 +02:00
|
|
|
import {showErrorAPI} from "../../utils/functions/showErrorAPI";
|
2024-07-27 14:40:08 +02:00
|
|
|
|
2024-07-26 16:45:10 +02:00
|
|
|
export default function DomainSearchPage() {
|
2024-07-27 17:02:21 +02:00
|
|
|
const [domain, setDomain] = useState<Domain | null>()
|
2024-07-27 01:35:00 +02:00
|
|
|
const [messageApi, contextHolder] = message.useMessage()
|
|
|
|
|
|
|
|
|
|
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
2024-07-27 17:02:21 +02:00
|
|
|
setDomain(null)
|
2024-07-27 16:45:20 +02:00
|
|
|
getDomain(values.ldhName).then(d => {
|
|
|
|
|
setDomain(d)
|
2024-07-28 15:36:22 +02:00
|
|
|
messageApi.success(t`Found !`)
|
2024-07-27 16:45:20 +02:00
|
|
|
}).catch((e: AxiosError) => {
|
2024-07-27 17:02:21 +02:00
|
|
|
setDomain(undefined)
|
2024-08-07 15:57:16 +02:00
|
|
|
showErrorAPI(e, messageApi)
|
2024-07-27 01:35:00 +02:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <Flex gap="middle" align="center" justify="center" vertical>
|
2024-08-23 21:19:34 +02:00
|
|
|
{contextHolder}
|
|
|
|
|
<DomainSearchBar onFinish={onFinish}/>
|
2024-07-27 14:40:08 +02:00
|
|
|
|
2024-08-23 21:19:34 +02:00
|
|
|
<Skeleton loading={domain === null} active>
|
|
|
|
|
{
|
|
|
|
|
domain &&
|
|
|
|
|
(!domain.deleted ? <DomainResult domain={domain}/>
|
|
|
|
|
: <Empty
|
|
|
|
|
description={t`Although the domain exists in my database, it has been deleted from the WHOIS by its registrar.`}/>)
|
|
|
|
|
}
|
|
|
|
|
</Skeleton>
|
2024-07-27 01:35:00 +02:00
|
|
|
</Flex>
|
2024-07-26 16:45:10 +02:00
|
|
|
}
|