From bd8a1130aaba41d8daefd3abf0594e58b20412ef Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 20 Feb 2023 00:48:58 -0600 Subject: [PATCH] Move all components into /components/ subfolders - Fixed last remaining axios to fetch switch --- src/components/{ => common}/DynamicDate.tsx | 0 src/components/{ => common}/Property.tsx | 0 src/components/form/LookupInput.tsx | 37 +++++++++++++ src/components/{ => lookup}/DomainCard.tsx | 4 +- src/components/{ => lookup}/Events.tsx | 2 +- src/components/{ => lookup}/Generic.tsx | 2 +- src/pages/index.tsx | 6 ++- src/pages/old.tsx | 5 +- yarn.lock | 57 --------------------- 9 files changed, 47 insertions(+), 66 deletions(-) rename src/components/{ => common}/DynamicDate.tsx (100%) rename src/components/{ => common}/Property.tsx (100%) create mode 100644 src/components/form/LookupInput.tsx rename src/components/{ => lookup}/DomainCard.tsx (93%) rename src/components/{ => lookup}/Events.tsx (92%) rename src/components/{ => lookup}/Generic.tsx (95%) diff --git a/src/components/DynamicDate.tsx b/src/components/common/DynamicDate.tsx similarity index 100% rename from src/components/DynamicDate.tsx rename to src/components/common/DynamicDate.tsx diff --git a/src/components/Property.tsx b/src/components/common/Property.tsx similarity index 100% rename from src/components/Property.tsx rename to src/components/common/Property.tsx diff --git a/src/components/form/LookupInput.tsx b/src/components/form/LookupInput.tsx new file mode 100644 index 0000000..1f7f370 --- /dev/null +++ b/src/components/form/LookupInput.tsx @@ -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; +} + +type LookupForm = { + target: string; +} + +const LookupInput: FunctionComponent = ({isLoading}: LookupInputProps) => { + const {register, handleSubmit} = useForm(); + + const onSubmit = (data: LookupForm) => { + return; + } + + return ( +
+ +
+ +
+
+ ) +} + +export default LookupInput; \ No newline at end of file diff --git a/src/components/DomainCard.tsx b/src/components/lookup/DomainCard.tsx similarity index 93% rename from src/components/DomainCard.tsx rename to src/components/lookup/DomainCard.tsx index f642682..fb11367 100644 --- a/src/components/DomainCard.tsx +++ b/src/components/lookup/DomainCard.tsx @@ -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; diff --git a/src/components/Events.tsx b/src/components/lookup/Events.tsx similarity index 92% rename from src/components/Events.tsx rename to src/components/lookup/Events.tsx index 07e84c9..127f472 100644 --- a/src/components/Events.tsx +++ b/src/components/lookup/Events.tsx @@ -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[]; diff --git a/src/components/Generic.tsx b/src/components/lookup/Generic.tsx similarity index 95% rename from src/components/Generic.tsx rename to src/components/lookup/Generic.tsx index 7b0921a..7022139 100644 --- a/src/components/Generic.tsx +++ b/src/components/lookup/Generic.tsx @@ -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; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index c768996..b045b58 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -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 = () => {
+
{ 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); diff --git a/yarn.lock b/yarn.lock index cf0d800..57f47a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -427,11 +427,6 @@ ast-types-flow@^0.0.7: resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" integrity sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag== -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - autoprefixer@^10.4.7: version "10.4.13" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.13.tgz#b5136b59930209a321e9fa3dca2e7c4d223e83a8" @@ -454,15 +449,6 @@ axe-core@^4.6.2: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.6.2.tgz#6e566ab2a3d29e415f5115bc0fd2597a5eb3e5e3" integrity sha512-b1WlTV8+XKLj9gZy2DZXgQiyDp9xkkoe2a6U6UbYccScq2wgH/YwCeI2/Jq2mgo0HzQxqJOjWZBLeA/mqsk5Mg== -axios@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.2.tgz#72681724c6e6a43a9fea860fc558127dbe32f9f1" - integrity sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q== - dependencies: - follow-redirects "^1.15.0" - form-data "^4.0.0" - proxy-from-env "^1.1.0" - axobject-query@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.1.1.tgz#3b6e5c6d4e43ca7ba51c5babf99d22a9c68485e1" @@ -568,13 +554,6 @@ color-name@^1.1.4, color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -676,11 +655,6 @@ defined@^1.0.0: resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.1.tgz#c0b9db27bfaffd95d6f61399419b893df0f91ebf" integrity sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q== -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - detective@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.1.tgz#6af01eeda11015acb0e73f933242b70f24f91034" @@ -1121,11 +1095,6 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== -follow-redirects@^1.15.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== - for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -1133,15 +1102,6 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - fraction.js@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.0.tgz#448e5109a313a3527f5a3ab2119ec4cf0e0e2950" @@ -1687,18 +1647,6 @@ micromatch@^4.0.4, micromatch@^4.0.5: braces "^3.0.2" picomatch "^2.3.1" -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -2029,11 +1977,6 @@ prop-types@^15.8.1: object-assign "^4.1.1" react-is "^16.13.1" -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - punycode@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.2.0.tgz#2092cc57cd2582c38e4e7e8bb869dc8d3148bc74"