mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
feat: update front layout
This commit is contained in:
parent
3b890c83f6
commit
df81d12a50
@ -1,5 +1,5 @@
|
||||
import React, {useState} from "react";
|
||||
import {Card, Divider, Flex, Form, FormProps, Input, message, Timeline} from "antd";
|
||||
import {Badge, Card, Divider, Flex, Form, FormProps, Input, message, Space, Timeline, Typography} from "antd";
|
||||
import {
|
||||
ClockCircleOutlined,
|
||||
DeleteOutlined,
|
||||
@ -12,20 +12,22 @@ import {Domain, getDomain} from "../../utils/api";
|
||||
import {AxiosError} from "axios"
|
||||
|
||||
|
||||
const {Title} = Typography
|
||||
|
||||
type FieldType = {
|
||||
ldhName: string
|
||||
}
|
||||
|
||||
export default function DomainSearchPage() {
|
||||
|
||||
const [domainData, setDomainData] = useState<Domain | null>(null)
|
||||
const [domain, setDomain] = useState<Domain | null>(null)
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
|
||||
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
||||
getDomain(values.ldhName).then(setDomainData).catch((e: AxiosError) => {
|
||||
getDomain(values.ldhName).then(setDomain).catch((e: AxiosError) => {
|
||||
const data = e?.response?.data as { detail: string }
|
||||
messageApi.error(data.detail ?? 'An error occurred')
|
||||
|
||||
setDomain(null)
|
||||
})
|
||||
}
|
||||
|
||||
@ -56,44 +58,58 @@ export default function DomainSearchPage() {
|
||||
<Input size="large" prefix={<SearchOutlined/>} placeholder="example.com"/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Divider/>
|
||||
|
||||
{
|
||||
domainData && <>
|
||||
<Timeline
|
||||
mode="right"
|
||||
items={domainData.events
|
||||
.sort((e1, e2) => new Date(e2.date).getTime() - new Date(e1.date).getTime())
|
||||
.map(({action, date}) => {
|
||||
domain && <>
|
||||
<Divider/>
|
||||
<Space direction="vertical" size="middle" style={{width: '100%'}}>
|
||||
<Badge.Ribbon text={`.${domain.tld.tld.toUpperCase()} (${domain.tld.type})`}
|
||||
color={
|
||||
domain.tld.type === 'ccTLD' ? 'purple' :
|
||||
(domain.tld.type === 'gTLD' && domain.tld.specification13) ? "volcano" :
|
||||
domain.tld.type === 'gTLD' ? "green"
|
||||
: "cyan"
|
||||
}>
|
||||
<Card title={`${domain.ldhName}${domain.handle ? ' (' + domain.handle + ')' : ''}`}
|
||||
size="small">
|
||||
|
||||
let color, dot
|
||||
if (action === 'registration') {
|
||||
color = 'green'
|
||||
dot = <SignatureOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'expiration') {
|
||||
color = 'red'
|
||||
dot = <ClockCircleOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'transfer') {
|
||||
color = 'orange'
|
||||
dot = <ShareAltOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'last changed') {
|
||||
color = 'blue'
|
||||
dot = <SyncOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'deletion') {
|
||||
color = 'red'
|
||||
dot = <DeleteOutlined style={{fontSize: '16px'}}/>
|
||||
}
|
||||
<Timeline
|
||||
mode="right"
|
||||
items={domain.events
|
||||
.sort((e1, e2) => new Date(e2.date).getTime() - new Date(e1.date).getTime())
|
||||
.map(({action, date}) => {
|
||||
|
||||
return {
|
||||
label: new Date(date).toUTCString(),
|
||||
children: action,
|
||||
color,
|
||||
dot,
|
||||
pending: new Date(date).getTime() > new Date().getTime()
|
||||
let color, dot
|
||||
if (action === 'registration') {
|
||||
color = 'green'
|
||||
dot = <SignatureOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'expiration') {
|
||||
color = 'red'
|
||||
dot = <ClockCircleOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'transfer') {
|
||||
color = 'orange'
|
||||
dot = <ShareAltOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'last changed') {
|
||||
color = 'blue'
|
||||
dot = <SyncOutlined style={{fontSize: '16px'}}/>
|
||||
} else if (action === 'deletion') {
|
||||
color = 'red'
|
||||
dot = <DeleteOutlined style={{fontSize: '16px'}}/>
|
||||
}
|
||||
return {
|
||||
label: new Date(date).toUTCString(),
|
||||
children: action,
|
||||
color,
|
||||
dot,
|
||||
pending: new Date(date).getTime() > new Date().getTime()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
/>
|
||||
/>
|
||||
</Card>
|
||||
</Badge.Ribbon>
|
||||
</Space>
|
||||
</>
|
||||
}
|
||||
</Card>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user