From 0d6cda47feaee614e9b7ad8db18d72dc01eb04e1 Mon Sep 17 00:00:00 2001 From: Sergii Bomko <1164492+aquiladev@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:10:36 +0300 Subject: [PATCH] add search --- package.json | 6 +- src/DefaultApp.js | 4 + src/components/BuyDomain.js | 84 ++++ src/components/Header.js | 78 ++- src/components/Search.js | 184 +++++++ src/services/udRegistry.js | 17 + yarn.lock | 944 ++++++++++++++++++++++-------------- 7 files changed, 948 insertions(+), 369 deletions(-) create mode 100644 src/components/BuyDomain.js create mode 100644 src/components/Search.js create mode 100644 src/services/udRegistry.js diff --git a/package.json b/package.json index 5362ef4..e2a63a5 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@gnosis.pm/safe-apps-provider": "0.9.2", "@gnosis.pm/safe-apps-react-sdk": "4.0.8", "@gnosis.pm/safe-react-components": "0.5.0", - "@material-ui/core": "4.11.2", + "@material-ui/core": "4.12.4", "@material-ui/icons": "4.11.2", "@material-ui/lab": "4.0.0-alpha.57", "@metamask/jazzicon": "^2.0.0", @@ -32,7 +32,7 @@ "react-router-dom": "^5.3.0", "react-scripts": "4.0.1", "styled-components": "5.2.3", - "uns": "https://github.com/unstoppabledomains/uns#v0.6.20", + "uns": "https://github.com/unstoppabledomains/uns#v0.8.36", "web-vitals": "^0.2.4" }, "scripts": { @@ -60,4 +60,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file diff --git a/src/DefaultApp.js b/src/DefaultApp.js index 3b274c3..80efe91 100644 --- a/src/DefaultApp.js +++ b/src/DefaultApp.js @@ -24,6 +24,7 @@ import GlobalStyle from "./components/GlobalStyle"; import { useEagerConnect, useInactiveListener } from "./hooks"; import Domains from "./components/Domains"; import Lookup from "./components/Lookup"; +import Search from "./components/Search"; import Header from "./components/Header"; import Footer from "./components/Footer"; import DeprecatedNetwork from "./components/DeprecatedNetwork"; @@ -134,6 +135,9 @@ function DefaultApp() { {active && } + + {active && } + {active && } diff --git a/src/components/BuyDomain.js b/src/components/BuyDomain.js new file mode 100644 index 0000000..b4b63f3 --- /dev/null +++ b/src/components/BuyDomain.js @@ -0,0 +1,84 @@ +import React, { useState } from "react"; +import { makeStyles } from "@material-ui/core/styles"; +import Typography from "@material-ui/core/Typography"; +import { Chip } from "@material-ui/core"; +import Accordion from "@material-ui/core/Accordion"; +import AccordionSummary from "@material-ui/core/AccordionSummary"; +import Button from "@material-ui/core/Button"; +import Alert from "@material-ui/lab/Alert"; + +import { getPurchaseParams } from "../services/udRegistry"; + +const useStyles = makeStyles((theme) => ({ + grow: { + flexGrow: 1, + paddingLeft: 30, + }, + buy: { + marginLeft: 16, + fontWeight: "bold", + }, + acc: { + marginBottom: 16, + }, + accSum: { + "& > .Mui-expanded": { + margin: "initial", + }, + }, +})); + +const BuyDomain = ({ name, status, price }) => { + const classes = useStyles(); + + const [fetched, setFetched] = useState(true); + const [error, setError] = useState(undefined); + + const handleBuy = async () => { + try { + setError(undefined); + setFetched(false); + const res = await getPurchaseParams(name); + console.log("RES", res); + } catch (error) { + console.error(error.message); + // setError(error.message); + setError("Comming soon..."); + } finally { + setFetched(true); + } + }; + + return ( + <> + + + + {name} + + +
+ + USD {(price / 100).toFixed(2)} + + +
+
+ {error && {error}} + + ); +}; + +export default BuyDomain; diff --git a/src/components/Header.js b/src/components/Header.js index 33ec0c9..386f08c 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,6 +1,6 @@ import React, { useState } from "react"; -import { Link } from "react-router-dom"; -import { makeStyles } from "@material-ui/core/styles"; +import { Link, useHistory } from "react-router-dom"; +import { alpha, makeStyles } from "@material-ui/core/styles"; import AppBar from "@material-ui/core/AppBar"; import Toolbar from "@material-ui/core/Toolbar"; import Typography from "@material-ui/core/Typography"; @@ -11,6 +11,7 @@ import MenuItem from "@material-ui/core/MenuItem"; import MoreVertIcon from "@material-ui/icons/MoreVert"; import BarChartIcon from "@material-ui/icons/BarChart"; import CodeIcon from "@material-ui/icons/Code"; +import InputBase from "@material-ui/core/InputBase"; import ConnectButton from "./ConnectButton"; @@ -38,20 +39,72 @@ const useStyles = makeStyles((theme) => ({ color: "inherit", textDecoration: "none", }, + search: { + position: "relative", + borderRadius: theme.shape.borderRadius, + backgroundColor: alpha(theme.palette.common.black, 0.15), + "&:hover": { + backgroundColor: alpha(theme.palette.common.black, 0.25), + }, + marginRight: theme.spacing(2), + marginLeft: 0, + width: "100%", + [theme.breakpoints.up("sm")]: { + marginLeft: theme.spacing(3), + width: "auto", + }, + }, + searchIcon: { + padding: theme.spacing(0, 2), + height: "100%", + position: "absolute", + pointerEvents: "none", + display: "flex", + alignItems: "center", + justifyContent: "center", + }, + inputRoot: { + color: "inherit", + }, + inputInput: { + padding: theme.spacing(1, 1, 1, 0), + // vertical padding + font size from searchIcon + paddingLeft: `calc(1em + ${theme.spacing(4)}px)`, + transition: theme.transitions.create("width"), + width: "100%", + [theme.breakpoints.up("md")]: { + width: "20ch", + }, + }, })); export default function Header({ active }) { const classes = useStyles(); + const history = useHistory(); const [anchorEl, setAnchorEl] = useState(null); + const [domainName, setDomainName] = useState(); const open = Boolean(anchorEl); + const handleOpen = (event) => { setAnchorEl(event.currentTarget); }; + const handleClose = () => { setAnchorEl(null); }; + const handleChange = (e) => { + setDomainName(e.target.value); + }; + + const keyPress = (e) => { + if (e.charCode === 13) { + setDomainName(""); + history.push(`/search/${domainName}`); + } + }; + return (
@@ -62,6 +115,23 @@ export default function Header({ active }) {
+
+
+ +
+ +