From 0292e5614bdf89e7af82607ab35367041fba2d17 Mon Sep 17 00:00:00 2001 From: Fernando Falci Date: Tue, 23 Apr 2024 10:24:20 +0200 Subject: [PATCH] chore: improve responsibility --- src/App.jsx | 79 +++++++++++++------------------- src/components/Badge.jsx | 2 +- src/components/Debug.jsx | 27 +++++++++++ src/components/search/Search.jsx | 60 +++++++++--------------- 4 files changed, 81 insertions(+), 87 deletions(-) create mode 100644 src/components/Debug.jsx diff --git a/src/App.jsx b/src/App.jsx index 5062084..61512e6 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -15,62 +15,47 @@ function App() { useDocumentTitle(PAGE_TITLE); return (
-
-
-
- -
- -
+
+ +
+
+ {HERO_TEXT}
-
-
-
-
- {HERO_TEXT} -
-
- {SUB_TEXT} -
-
-
+
+ {SUB_TEXT} +
+
-
-
-
-
+
+
+
); diff --git a/src/components/Badge.jsx b/src/components/Badge.jsx index affc255..5c6cb4f 100644 --- a/src/components/Badge.jsx +++ b/src/components/Badge.jsx @@ -5,7 +5,7 @@ export const Badge = ({ children, variant, title }) => (
{ + if (!DEV_MODE) return; + + return ( +
+ + TESTNET + + {error && ( +
{error}
+ )} + {data && ( +
+          {JSON.stringify(data, null, 2)}
+        
+ )} +
+ ); +}; + +Debug.propTypes = { + error: PropTypes.any, + data: PropTypes.any, +}; diff --git a/src/components/search/Search.jsx b/src/components/search/Search.jsx index 2092aed..c57c343 100644 --- a/src/components/search/Search.jsx +++ b/src/components/search/Search.jsx @@ -1,12 +1,13 @@ -import { useState } from 'react'; import { useDebounce } from '@uidotdev/usehooks'; +import { useState } from 'react'; import { SearchInput } from './SearchInput'; import { SearchStatus } from './SearchStatus'; +import { TLD } from '../../constants'; +import { useDomainStatus } from '../../hooks/useDomainStatus'; +import { Debug } from '../Debug'; import { SearchCTA } from './SearchCTA'; import { SearchPrice } from './SearchPrice'; -import { DEV_MODE, TLD } from '../../constants'; -import { useDomainStatus } from '../../hooks/useDomainStatus'; export const Search = () => { // "term" is the value from the input (first part if it contains a ".") @@ -23,56 +24,37 @@ export const Search = () => { const show = !!label; // if there's a "." (like "foo.bar"), we only use the first part (foo) - const onChange = (term) => setTerm(term.split('.').at(0)); + const onChange = (term = '') => setTerm(term.toLowerCase().split('.').at(0)); // ensure the current data is related to the final search term const safeData = term === data?.label ? data : undefined; return ( <> -
+
{show && ( -
-
-
-
- - {label} - - - .{TLD} - -
+
+
+
+ {label} + .{TLD} +
- -
-
- - -
+ +
+
+ +
)}
- {DEV_MODE && ( -
- - TESTNET - - {error && ( -
- {error} -
- )} - {data && ( -
-              {JSON.stringify(data, null, 2)}
-            
- )} -
- )} + ); };