feat: add eslint linter

This commit is contained in:
Maël Gangloff
2024-12-30 23:50:15 +01:00
parent ebfcc58d16
commit 99d135cc31
64 changed files with 3579 additions and 1846 deletions

View File

@@ -1,12 +1,12 @@
import React, {useEffect, useState} from "react";
import {Empty, Flex, FormProps, message, Skeleton} from "antd";
import {Domain, getDomain} from "../../utils/api";
import {AxiosError} from "axios"
import React, {useEffect, useState} from 'react'
import {Empty, Flex, FormProps, message, Skeleton} from 'antd'
import {Domain, getDomain} from '../../utils/api'
import {AxiosError} from 'axios'
import {t} from 'ttag'
import {DomainSearchBar, FieldType} from "../../components/search/DomainSearchBar";
import {DomainResult} from "../../components/search/DomainResult";
import {showErrorAPI} from "../../utils/functions/showErrorAPI";
import {useNavigate, useParams} from "react-router-dom";
import {DomainSearchBar, FieldType} from '../../components/search/DomainSearchBar'
import {DomainResult} from '../../components/search/DomainResult'
import {showErrorAPI} from '../../utils/functions/showErrorAPI'
import {useNavigate, useParams} from 'react-router-dom'
export default function DomainSearchPage() {
const {query} = useParams()
@@ -36,17 +36,21 @@ export default function DomainSearchPage() {
onFinish({ldhName: query})
}, [])
return <Flex gap="middle" align="center" justify="center" vertical>
{contextHolder}
<DomainSearchBar initialValue={query} onFinish={onFinish}/>
return (
<Flex gap='middle' align='center' justify='center' vertical>
{contextHolder}
<DomainSearchBar initialValue={query} onFinish={onFinish}/>
<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>
</Flex>
}
<Skeleton loading={domain === null} active>
{
(domain != null) &&
(!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>
</Flex>
)
}

View File

@@ -1,7 +1,9 @@
import React from "react";
import React from 'react'
export default function EntitySearchPage() {
return <p>
Not implemented
</p>
}
return (
<p>
Not implemented
</p>
)
}

View File

@@ -1,7 +1,9 @@
import React from "react";
import React from 'react'
export default function NameserverSearchPage() {
return <p>
Not implemented
</p>
}
return (
<p>
Not implemented
</p>
)
}

View File

@@ -1,41 +1,53 @@
import React, {useEffect, useState} from "react";
import {Collapse, Divider, Table, Typography} from "antd";
import {getTldList, Tld} from "../../utils/api";
import React, {ReactElement, useEffect, useState} from 'react'
import {Collapse, Divider, Table, Typography} from 'antd'
import {getTldList, Tld} from '../../utils/api'
import {t} from 'ttag'
import {regionNames} from "../../i18n";
import useBreakpoint from "../../hooks/useBreakpoint";
import {ColumnType} from "antd/es/table";
import punycode from "punycode/punycode";
import {getCountryCode} from "../../utils/functions/getCountryCode";
import {tldToEmoji} from "../../utils/functions/tldToEmoji";
import {regionNames} from '../../i18n'
import useBreakpoint from '../../hooks/useBreakpoint'
import {ColumnType} from 'antd/es/table'
import punycode from 'punycode/punycode'
import {getCountryCode} from '../../utils/functions/getCountryCode'
import {tldToEmoji} from '../../utils/functions/tldToEmoji'
const {Text, Paragraph} = Typography
type TldType = 'iTLD' | 'sTLD' | 'gTLD' | 'ccTLD'
type FiltersType = { type: TldType, contractTerminated?: boolean, specification13?: boolean }
interface FiltersType {
type: TldType,
contractTerminated?: boolean,
specification13?: boolean
}
function TldTable(filters: FiltersType) {
interface TableRow {
key: string
TLD: ReactElement
Flag?: string
Country?: string
}
const sm = useBreakpoint('sm')
const [dataTable, setDataTable] = useState<Tld[]>([])
const [dataTable, setDataTable] = useState<TableRow[]>([])
const [total, setTotal] = useState(0)
const fetchData = (params: FiltersType & { page: number, itemsPerPage: number }) => {
getTldList(params).then((data) => {
setTotal(data['hydra:totalItems'])
setDataTable(data['hydra:member'].map((tld: Tld) => {
const rowData = {
key: tld.tld,
TLD: <Typography.Text code>{punycode.toUnicode(tld.tld)}</Typography.Text>
}
switch (filters.type) {
const type = filters.type
let countryName
switch (type) {
case 'ccTLD':
let countryName
try {
countryName = regionNames.of(getCountryCode(tld.tld))
} catch (e) {
} catch {
countryName = '-'
}
@@ -60,98 +72,104 @@ function TldTable(filters: FiltersType) {
fetchData({...filters, page: 1, itemsPerPage: 30})
}, [])
let columns: ColumnType<any>[] = [
let columns: Array<ColumnType<TableRow>> = [
{
title: t`TLD`,
dataIndex: "TLD"
dataIndex: 'TLD'
}
]
if (filters.type === 'ccTLD') columns = [...columns, {
title: t`Flag`,
dataIndex: "Flag",
}, {
title: t`Country`,
dataIndex: "Country"
}]
if (filters.type === 'ccTLD') {
columns = [...columns, {
title: t`Flag`,
dataIndex: 'Flag'
}, {
title: t`Country`,
dataIndex: 'Country'
}]
}
if (filters.type === 'gTLD') columns = [...columns, {
title: t`Registry Operator`,
dataIndex: "Operator"
}]
if (filters.type === 'gTLD') {
columns = [...columns, {
title: t`Registry Operator`,
dataIndex: 'Operator'
}]
}
return (
<Table
columns={columns}
dataSource={dataTable}
pagination={{
total,
hideOnSinglePage: true,
defaultPageSize: 30,
onChange: (page, itemsPerPage) => {
fetchData({...filters, page, itemsPerPage})
}
}}
return <Table
columns={columns}
dataSource={dataTable}
pagination={{
total,
hideOnSinglePage: true,
defaultPageSize: 30,
onChange: (page, itemsPerPage) => {
fetchData({...filters, page, itemsPerPage})
}
}}
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})}
/>
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})}
/>
)
}
export default function TldPage() {
const sm = useBreakpoint('sm')
return <>
<Paragraph>
{t`This page presents all active TLDs in the root zone database.`}
</Paragraph>
<Paragraph>
{t`IANA provides the list of currently active TLDs, regardless of their type, and ICANN provides the list of gTLDs.
return (
<>
<Paragraph>
{t`This page presents all active TLDs in the root zone database.`}
</Paragraph>
<Paragraph>
{t`IANA provides the list of currently active TLDs, regardless of their type, and ICANN provides the list of gTLDs.
In most cases, the two-letter ccTLD assigned to a country is made in accordance with the ISO 3166-1 standard.
This data is updated every month. Three HTTP requests are needed for the complete update of TLDs in Domain Watchdog (two requests to IANA and one to ICANN).
At the same time, the list of root RDAP servers is updated.`}
</Paragraph>
<Divider/>
<Collapse
accordion
size={sm ? 'small' : 'large'}
items={[
{
key: 'sTLD',
label: t`Sponsored Top-Level-Domains`,
children: <>
<Text>{t`Top-level domains sponsored by specific organizations that set rules for registration and use, often related to particular interest groups or industries.`}</Text>
<Divider/>
<TldTable type='sTLD'/>
</>
},
{
key: 'gTLD',
label: t`Generic Top-Level-Domains`,
children: <>
<Text>{t`Generic top-level domains open to everyone, not restricted by specific criteria, representing various themes or industries.`}</Text>
<Divider/>
<TldTable type='gTLD' contractTerminated={false} specification13={false}/>
</>
},
{
key: 'ngTLD',
label: t`Brand Generic Top-Level-Domains`,
children: <>
<Text>{t`Generic top-level domains associated with specific brands, allowing companies to use their own brand names as domains.`}</Text>
<Divider/>
<TldTable type='gTLD' contractTerminated={false} specification13={true}/>
</>
},
{
key: 'ccTLD',
label: t`Country-Code Top-Level-Domains`,
children: <>
<Text>{t`Top-level domains based on country codes, identifying websites according to their country of origin.`}</Text>
<Divider/><TldTable type='ccTLD'/>
</>
}
]}
/>
</>
}
</Paragraph>
<Divider/>
<Collapse
accordion
size={sm ? 'small' : 'large'}
items={[
{
key: 'sTLD',
label: t`Sponsored Top-Level-Domains`,
children: <>
<Text>{t`Top-level domains sponsored by specific organizations that set rules for registration and use, often related to particular interest groups or industries.`}</Text>
<Divider/>
<TldTable type='sTLD'/>
</>
},
{
key: 'gTLD',
label: t`Generic Top-Level-Domains`,
children: <>
<Text>{t`Generic top-level domains open to everyone, not restricted by specific criteria, representing various themes or industries.`}</Text>
<Divider/>
<TldTable type='gTLD' contractTerminated={false} specification13={false}/>
</>
},
{
key: 'ngTLD',
label: t`Brand Generic Top-Level-Domains`,
children: <>
<Text>{t`Generic top-level domains associated with specific brands, allowing companies to use their own brand names as domains.`}</Text>
<Divider/>
<TldTable type='gTLD' contractTerminated={false} specification13/>
</>
},
{
key: 'ccTLD',
label: t`Country-Code Top-Level-Domains`,
children: <>
<Text>{t`Top-level domains based on country codes, identifying websites according to their country of origin.`}</Text>
<Divider/><TldTable type='ccTLD'/>
</>
}
]}
/>
</>
)
}