diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx new file mode 100644 index 0000000..19acc9f --- /dev/null +++ b/src/components/Loading.tsx @@ -0,0 +1,9 @@ +const Loading = () => { + return ( +
+ +
+ ); +}; + +export default Loading; diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 1fea2bb..1452191 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -3,7 +3,7 @@ import SearchForm from './SearchForm'; const Navbar = () => { return ( -
+
diff --git a/src/components/SearchForm.tsx b/src/components/SearchForm.tsx index 7690903..e98a0ca 100644 --- a/src/components/SearchForm.tsx +++ b/src/components/SearchForm.tsx @@ -30,6 +30,7 @@ const SearchForm = () => { historyPush(searchQuery); setSearchParams({ domain: searchQuery }); navigate(`/results?domain=${encodeURIComponent(searchQuery)}`); + setTimeout(() => window.scroll(0, 0), 50); }; const handleKeyUp = (event: KeyboardEvent): void => { diff --git a/src/components/SslTable.tsx b/src/components/SslTable.tsx index 3169e10..08659ec 100644 --- a/src/components/SslTable.tsx +++ b/src/components/SslTable.tsx @@ -1,16 +1,41 @@ -import React from 'react'; +import React, { useMemo } from 'react'; +import { getDays } from '../helpers/getDays'; +import { SslStatus } from '../enums/SslStatus.enum'; +import Loading from './Loading'; const SslTable: React.FC<{ // eslint-disable-next-line @typescript-eslint/no-explicit-any content: Record | undefined; loading: boolean; }> = ({ content, loading }) => { + const sslRows = useMemo(() => { + if (!content) return []; + + const { issuer, dns_names, not_before, not_after } = content; + const remainingDays = getDays(not_after); + + const transformedSslObj = { + Status: remainingDays > 0 ? SslStatus.ACTIVE : SslStatus.EXPIRED, + Issuer: issuer.friendly_name, + Covers: Array.isArray(dns_names) ? dns_names.join(', ') : dns_names, + Issued_On: new Date(not_before).toLocaleDateString(), + Expires_On: `${new Date( + not_after + ).toLocaleDateString()} (in ${remainingDays} days)`, + }; + + return Object.entries(transformedSslObj).map( + ([key, value]: [string, string | string[]]) => ({ + label: key.replace(/_/g, ' '), + value, + }) + ); + }, [content]); + return (
{loading ? ( -
- -
+ ) : !content ? (

No SSL certificate found.

@@ -18,22 +43,12 @@ const SslTable: React.FC<{ ) : ( - - - - - - - - - - - - - - - - + {sslRows.map(({ label, value }) => ( + + + + + ))}
Issuer{content.issuer?.friendly_name}
Covers{content.dns_names?.join(', ')}
Issued On{new Date(content.not_before).toLocaleDateString()}
Expires On{new Date(content.not_after).toLocaleDateString()}
{label}{value}
)} diff --git a/src/components/WhoisTable.tsx b/src/components/WhoisTable.tsx index 7d2d0a4..236d8ec 100644 --- a/src/components/WhoisTable.tsx +++ b/src/components/WhoisTable.tsx @@ -1,5 +1,6 @@ import React, { useMemo } from 'react'; import { getDays } from '../helpers/getDays'; +import Loading from './Loading'; const WhoisTable: React.FC<{ // eslint-disable-next-line @typescript-eslint/no-explicit-any content: Record | undefined; @@ -24,9 +25,9 @@ const WhoisTable: React.FC<{ ? name_servers : name_servers.substring(0, name_servers.indexOf(' ')), Registered_On: new Date(creation_date).toLocaleDateString(), - Expires_On: `${new Date(expiration_date).toLocaleDateString()} (${getDays( + Expires_On: `${new Date( expiration_date - )} days)`, + ).toLocaleDateString()} (in ${getDays(expiration_date)} days)`, Last_updated_On: new Date(updated_date).toLocaleDateString(), Status: Array.isArray(status) ? status.map((s: string) => s.substring(0, s.indexOf(' '))) @@ -45,9 +46,7 @@ const WhoisTable: React.FC<{ return (
{loading ? ( -
- -
+ ) : !content ? (

Whois data could not be fetched.

@@ -55,18 +54,18 @@ const WhoisTable: React.FC<{ ) : ( - {whoisRows.map(row => ( - - + {whoisRows.map(({ label, value }) => ( + + diff --git a/src/enums/SslStatus.enum.ts b/src/enums/SslStatus.enum.ts new file mode 100644 index 0000000..c5b3d2c --- /dev/null +++ b/src/enums/SslStatus.enum.ts @@ -0,0 +1,4 @@ +export enum SslStatus { + ACTIVE = 'Active', + EXPIRED = 'Expired', +} diff --git a/src/index.css b/src/index.css index bb67ee6..7bee2b2 100644 --- a/src/index.css +++ b/src/index.css @@ -36,4 +36,5 @@ html { https://github.com/saadeghi/daisyui/issues/3040#issuecomment-2131174823 */ scrollbar-gutter: auto !important; + scroll-behavior: smooth; } diff --git a/src/views/Results.tsx b/src/views/Results.tsx index e6b76cc..5de513c 100644 --- a/src/views/Results.tsx +++ b/src/views/Results.tsx @@ -100,8 +100,8 @@ const Results = () => { return ( <> - -

+ +

Looking up {searchParams.get('domain')}

{row.label}
{label} - {Array.isArray(row.value) ? ( + {Array.isArray(value) ? (
    - {row.value.map((r: string, idx: number) => ( + {value.map((r: string, idx: number) => (
  • {r}
  • ))}
) : ( - row.value + value )}