From eaab8ce1b2e65a7e9ca95b3917768af6b2cd059f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Sat, 27 Jul 2024 17:02:21 +0200 Subject: [PATCH] feat: add skeleton on Domain Finder page --- assets/pages/search/DomainSearchPage.tsx | 216 ++++++++++++----------- assets/pages/watchdog/UserPage.tsx | 26 ++- 2 files changed, 135 insertions(+), 107 deletions(-) diff --git a/assets/pages/search/DomainSearchPage.tsx b/assets/pages/search/DomainSearchPage.tsx index 8e13570..6472af9 100644 --- a/assets/pages/search/DomainSearchPage.tsx +++ b/assets/pages/search/DomainSearchPage.tsx @@ -11,6 +11,7 @@ import { Input, List, message, + Skeleton, Space, Tag, Timeline, @@ -21,6 +22,7 @@ import { ClockCircleOutlined, DeleteOutlined, IdcardOutlined, + ReloadOutlined, SearchOutlined, ShareAltOutlined, SignatureOutlined, @@ -40,16 +42,17 @@ type FieldType = { export default function DomainSearchPage() { - const [domain, setDomain] = useState(null) + const [domain, setDomain] = useState() const [messageApi, contextHolder] = message.useMessage() const onFinish: FormProps['onFinish'] = (values) => { + setDomain(null) getDomain(values.ldhName).then(d => { setDomain(d) messageApi.success('Found !') }).catch((e: AxiosError) => { const data = e?.response?.data as { detail: string } - setDomain(null) + setDomain(undefined) messageApi.error(data.detail ?? 'An error occurred') }) } @@ -77,113 +80,120 @@ export default function DomainSearchPage() { min: 2 }]} > - } placeholder="example.com"/> + } placeholder="example.com" autoFocus={true} + autoComplete='off'/> - { - domain && - (!domain.deleted ? - - - {domain.status.length > 0 && - <> - EPP Status Codes - - { - domain.status.map(s => - {s} - ) - } - - - } - Timeline - new Date(e2.date).getTime() - new Date(e1.date).getTime()) - .map(({action, date}) => { - - let color, dot - if (action === 'registration') { - color = 'green' - dot = - } else if (action === 'expiration') { - color = 'red' - dot = - } else if (action === 'transfer') { - color = 'orange' - dot = - } else if (action === 'last changed') { - color = 'blue' - dot = - } else if (action === 'deletion') { - color = 'red' - dot = + + { + domain && + (!domain.deleted ? + + + {domain.status.length > 0 && + <> + EPP Status Codes + + { + domain.status.map(s => + {s} + ) } - return { - label: new Date(date).toUTCString(), - children: action, - color, - dot, - pending: new Date(date).getTime() > new Date().getTime() - } - } - ) + + } - /> - { - domain.entities.length > 0 && - <> - Entities - { - const jCard = vCard.fromJSON(e.entity.jCard) - let name = '' - if (jCard.data.fn !== undefined && !Array.isArray(jCard.data.fn)) name = jCard.data.fn.valueOf() + Timeline + new Date(e2.date).getTime() - new Date(e1.date).getTime()) + .map(({action, date}) => { - return - : e.roles.includes('registrar') ? - : - e.roles.includes('technical') ? - : - e.roles.includes('administrative') ? - : - }/>} - title={e.entity.handle} - description={name} - /> -
{e.roles.join(', ')}
-
- }} - /> - - } -
-
-
- : - Although the domain exists in my database, it has been deleted from the WHOIS by its - registrar. - - }/>) - } + let color, dot + if (action === 'registration') { + color = 'green' + dot = + } else if (action === 'expiration') { + color = 'red' + dot = + } else if (action === 'transfer') { + color = 'orange' + dot = + } else if (action === 'last changed') { + color = 'blue' + dot = + } else if (action === 'deletion') { + color = 'red' + dot = + } else if (action === 'reregistration') { + color = 'green' + dot = + } + + return { + label: new Date(date).toUTCString(), + children: action, + color, + dot, + pending: new Date(date).getTime() > new Date().getTime() + } + } + ) + } + /> + { + domain.entities.length > 0 && + <> + Entities + { + const jCard = vCard.fromJSON(e.entity.jCard) + let name = '' + if (jCard.data.fn !== undefined && !Array.isArray(jCard.data.fn)) name = jCard.data.fn.valueOf() + + return + : e.roles.includes('registrar') ? + : + e.roles.includes('technical') ? + : + e.roles.includes('administrative') ? + : + }/>} + title={e.entity.handle} + description={name} + /> +
{e.roles.join(', ')}
+
+ }} + /> + + } +
+
+
+ : + Although the domain exists in my database, it has been deleted from the WHOIS by its + registrar. + + }/>) + } + } \ No newline at end of file diff --git a/assets/pages/watchdog/UserPage.tsx b/assets/pages/watchdog/UserPage.tsx index 4f268a6..e6446b8 100644 --- a/assets/pages/watchdog/UserPage.tsx +++ b/assets/pages/watchdog/UserPage.tsx @@ -1,7 +1,25 @@ -import React from "react"; +import React, {useEffect, useState} from "react"; +import {Card, Flex, Skeleton, Typography} from "antd"; +import {getUser, User} from "../../utils/api"; export default function UserPage() { - return

- My Account Page -

+ + const [user, setUser] = useState(null) + + useEffect(() => { + getUser().then(setUser) + }, []) + + return + + + + Username : {user?.email} + + + Roles : {user?.roles.join(',')} + + + + } \ No newline at end of file