mirror of
https://github.com/Xevion/rdap.git
synced 2026-01-31 08:25:24 -06:00
Move all components into /components/ subfolders
- Fixed last remaining axios to fetch switch
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import {useForm} from "react-hook-form";
|
||||
import type {FunctionComponent} from "react";
|
||||
import {onPromise} from "@/helpers";
|
||||
import type {TargetType} from "@/types";
|
||||
|
||||
type LookupInputProps = {
|
||||
isLoading?: boolean
|
||||
onRegistry?: (type: TargetType) => Promise<void>;
|
||||
}
|
||||
|
||||
type LookupForm = {
|
||||
target: string;
|
||||
}
|
||||
|
||||
const LookupInput: FunctionComponent<LookupInputProps> = ({isLoading}: LookupInputProps) => {
|
||||
const {register, handleSubmit} = useForm<LookupForm>();
|
||||
|
||||
const onSubmit = (data: LookupForm) => {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={onPromise(handleSubmit(onSubmit))} className="form-inline">
|
||||
<input
|
||||
className="form-control bg-zinc-800 focus:bg-zinc-700 focus:border-zinc-600 border-zinc-700 text-zinc-200"
|
||||
{...register("target", {required: true})}
|
||||
placeholder="A domain, an IP address, a TLD, an RDAP URL..."
|
||||
disabled={isLoading}
|
||||
/>
|
||||
<div className="input-group-append">
|
||||
<input id="button" type="button" value="Submit" disabled={isLoading}/>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
export default LookupInput;
|
||||
@@ -2,8 +2,8 @@ import type {FunctionComponent} from "react";
|
||||
import React from "react";
|
||||
import {rdapStatusInfo} from "@/constants";
|
||||
import type {Domain} from "@/types";
|
||||
import Events from "@/components/Events"
|
||||
import Property from "@/components/Property";
|
||||
import Events from "@/components/lookup/Events"
|
||||
import Property from "@/components/common/Property";
|
||||
|
||||
export type DomainProps = {
|
||||
data: Domain;
|
||||
@@ -1,7 +1,7 @@
|
||||
import type {FunctionComponent} from "react";
|
||||
import type {Event} from "@/types";
|
||||
import {Fragment} from "react";
|
||||
import DynamicDate from "@/components/DynamicDate";
|
||||
import DynamicDate from "@/components/common/DynamicDate";
|
||||
|
||||
export type EventsProps = {
|
||||
data: Event[];
|
||||
@@ -1,5 +1,5 @@
|
||||
import type {FunctionComponent} from "react";
|
||||
import DomainCard from "@/components/DomainCard";
|
||||
import DomainCard from "@/components/lookup/DomainCard";
|
||||
import type {Domain, AutonomousNumber, Entity, Nameserver, IpNetwork} from "@/types";
|
||||
|
||||
export type ParsedGeneric = Domain | Nameserver | Entity | AutonomousNumber | IpNetwork;
|
||||
+4
-2
@@ -1,10 +1,11 @@
|
||||
import {type NextPage} from "next";
|
||||
import Head from "next/head";
|
||||
import {useRef, useState} from "react";
|
||||
import Generic, {type ParsedGeneric} from "@/components/Generic";
|
||||
import {useState} from "react";
|
||||
import Generic, {type ParsedGeneric} from "@/components/lookup/Generic";
|
||||
import useLookup from "@/hooks/useLookup";
|
||||
import {onPromise} from "@/helpers";
|
||||
import {OGP} from "react-ogp";
|
||||
import LookupInput from "@/components/form/LookupInput";
|
||||
|
||||
const Index: NextPage = () => {
|
||||
const {error, setTarget, submit, currentType} = useLookup();
|
||||
@@ -61,6 +62,7 @@ const Index: NextPage = () => {
|
||||
</span>
|
||||
</nav>
|
||||
<div className="container py-12 mx-auto max-w-screen-lg">
|
||||
<LookupInput />
|
||||
<form onSubmit={onPromise(async function (e) {
|
||||
e.preventDefault()
|
||||
|
||||
|
||||
+2
-3
@@ -6,8 +6,7 @@ import {domainMatch, getBestURL, getType} from "@/rdap";
|
||||
import type {FormEvent} from "react";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {truthy} from "@/helpers";
|
||||
import type {ParsedGeneric} from "@/components/Generic";
|
||||
import Generic from "@/components/Generic";
|
||||
import Generic, {type ParsedGeneric} from "@/components/lookup/Generic";
|
||||
import type {ZodSchema} from "zod";
|
||||
import {DomainSchema, RegisterSchema} from "@/schema";
|
||||
|
||||
@@ -144,7 +143,7 @@ const Old: NextPage = () => {
|
||||
setError('This object does not exist.');
|
||||
else if (response.status != 200)
|
||||
setError(`Error ${response.status}: ${response.statusText}`)
|
||||
data = schema.parse(response.data);
|
||||
data = schema.parse(await response.json());
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user