From c24462d7dbef0a430e6f2f95bd3db292cc33bb31 Mon Sep 17 00:00:00 2001 From: PRavaga Date: Fri, 23 Jun 2023 15:25:41 +0200 Subject: [PATCH] address, alias and amount validation Signed-off-by: PRavaga --- src/app/components/UI/MyInput/MyInput.jsx | 7 +- .../WalletSend/AddressInput/AddressInput.jsx | 100 ------------------ .../AddressInput/AddressInput.module.scss | 69 ------------ src/app/components/WalletSend/WalletSend.jsx | 51 +++++++-- 4 files changed, 44 insertions(+), 183 deletions(-) delete mode 100644 src/app/components/WalletSend/AddressInput/AddressInput.jsx delete mode 100644 src/app/components/WalletSend/AddressInput/AddressInput.module.scss diff --git a/src/app/components/UI/MyInput/MyInput.jsx b/src/app/components/UI/MyInput/MyInput.jsx index 5615b60..879ceeb 100644 --- a/src/app/components/UI/MyInput/MyInput.jsx +++ b/src/app/components/UI/MyInput/MyInput.jsx @@ -2,10 +2,9 @@ import React from "react"; import nextId from "react-id-generator"; import s from "./MyInput.module.scss"; -const MyInput = ({ label, value, noActiveBorder, ...props }) => { +const MyInput = ({ label, value, noActiveBorder, isValid, ...props }) => { const id = nextId(); - const inputClasses = - value.length && !noActiveBorder > 0 ? "_input-filled" : ""; + const inputClasses = isValid && !noActiveBorder > 0 ? "_input-filled" : ""; return (
@@ -21,4 +20,4 @@ const MyInput = ({ label, value, noActiveBorder, ...props }) => { ); }; -export default MyInput; \ No newline at end of file +export default MyInput; diff --git a/src/app/components/WalletSend/AddressInput/AddressInput.jsx b/src/app/components/WalletSend/AddressInput/AddressInput.jsx deleted file mode 100644 index 4f7ed5c..0000000 --- a/src/app/components/WalletSend/AddressInput/AddressInput.jsx +++ /dev/null @@ -1,100 +0,0 @@ -import React, { useEffect, useRef, useState } from "react"; -import checkIcon from "../../../assets/svg/check.svg"; -import aliasIcon from "../../../assets/svg/contacts.svg"; -import mainStyles from "../WalletSend.module.scss"; -import s from "./AddressInput.module.scss"; -import { getAliasDetails, getAlias } from "../../../../background/wallet"; - -const AddressInput = ({ address }) => { - const textareaRef = useRef(null); - const [aliasVisible, setAliasVisible] = useState(false); - const [alias, setAlias] = useState({ value: "", address: "" }); - - const buttonClasses = aliasVisible - ? [s.addAliasBtn, s.active].join(" ") - : s.addAliasBtn; - - const getTextAreaClasses = () => { - const aliasVisibleClass = aliasVisible && address.value && s.thinText; - const inputFilledClass = address.value.length && "_input-filled"; - return [aliasVisibleClass, inputFilledClass].join(" "); - }; - - useEffect(() => { - handleInput(); - }, []); - - const handleInput = () => { - textareaRef.current.style.height = "41px"; - textareaRef.current.style.height = textareaRef.current.scrollHeight + "px"; - }; - - const toggleAlias = async () => { - if (!aliasVisible && address.value) { - const aliasValue = await getAlias(address.value); - if (aliasValue) { - setAlias({ value: aliasValue, address: address.value }); - setAliasVisible(true); - } else { - const addr = await getAliasDetails(address.value); - if (addr) { - setAlias({ value: address.value, address: addr }); - setAliasVisible(true); - } - } - } else { - setAliasVisible(!aliasVisible); - } - }; - - const handleAliasChange = async (e) => { - const aliasValue = e.target.value; - const addr = await getAliasDetails(aliasValue); - if (addr) { - setAlias({ value: aliasValue, address: addr }); - address.onChange({ target: { value: addr } }); // set address to resolved address from alias - setAliasVisible(true); - } - }; - - return ( -
- - -
- {aliasVisible && ( -
- @ - - check icon - -
- )} - -