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