import { type NextPage } from "next"; import Head from "next/head"; import { useState } from "react"; import Generic, { type ParsedGeneric } from "@/components/lookup/Generic"; import useLookup from "@/hooks/useLookup"; import { OGP } from "react-ogp"; import LookupInput from "@/components/form/LookupInput"; import ErrorCard from "@/components/common/ErrorCard"; import { Maybe } from "true-myth"; import type { ObjectType } from "@/types"; import { getType } from "@/rdap"; const Index: NextPage = () => { const { error, setTarget, submit } = useLookup(); const [detectedType, setDetectedType] = useState>(Maybe.nothing()); const [response, setResponse] = useState(); const [isLoading, setLoading] = useState(false); return ( <> rdap.xevion.dev
{ setTarget(target); const detectResult = getType(target); if (detectResult.isOk) { const value = detectResult.value; if (value == "ip4" || value == "ip6") setDetectedType(Maybe.just("ip")); else setDetectedType(Maybe.just(value)); } else { setDetectedType(Maybe.nothing()); } }} onSubmit={async function (props) { try { setLoading(true); const result = await submit(props); if (result.isJust) setResponse(result.value); else setResponse(null); setLoading(false); } catch (e) { setResponse(null); setLoading(false); } }} /> {error != null ? ( ) : null} {response != null ? : null}
); }; export default Index;