From e42bc8616e387f083de13f2984595a020560faef Mon Sep 17 00:00:00 2001 From: Alireza khaji Date: Sun, 22 May 2022 16:53:26 +0430 Subject: [PATCH] some debug --- src/components/input/index.js | 182 ++++++++++++++++++---------------- src/view/register/index.js | 5 + 2 files changed, 100 insertions(+), 87 deletions(-) diff --git a/src/components/input/index.js b/src/components/input/index.js index f52eafa..c5ab31a 100644 --- a/src/components/input/index.js +++ b/src/components/input/index.js @@ -3,95 +3,103 @@ import _onInput from "../../utils/onInput"; const Input = ({ - title, - borderType, - gapSize, - id, - type, - direction, - className, - onChange, - style, - bg, - value, - max, - onFocus + title, + borderType, + gapSize, + id, + type, + direction, + className, + onChange, + style, + bg, + value, + max, + onFocus, + defaultValue, }) => { - useEffect(() => { - - if(value !== null && value !== '' && value !== undefined){ - blurHandler2(id ? id : 0) - } - - }, [value]) + useEffect(() => { + if (value !== null && value !== "" && value !== undefined) { + blurHandler2(id ? id : 0); + } + }, [value]); - const focusHandler = (id) => { - let inputs = document.querySelectorAll(".Login-box-form-item"); - let label = document.querySelectorAll(".Login-box-form-item-label"); - let line = document.querySelectorAll(".Login-box-form-item-line"); - - inputs[id].style.borderColor = "#df1452"; - inputs[id].style.backgroundColor = "#fff"; - inputs[id].style.color = '#404040'; - label[id].style.transform = `translate(-10px,-27px)`; - label[id].style.color = "#df1452"; - line[id].style.backgroundColor = "#fff"; - - - }; + const focusHandler = (id) => { + let inputs = document.querySelectorAll(".Login-box-form-item"); + let label = document.querySelectorAll(".Login-box-form-item-label"); + let line = document.querySelectorAll(".Login-box-form-item-line"); - const blurHandler = (id) => { - let inputsBox = document.querySelectorAll(".Login-box-form-item"); - let inputs = document.querySelectorAll(".Login-box-form-item-input"); - let label = document.querySelectorAll(".Login-box-form-item-label"); - let line = document.querySelectorAll(".Login-box-form-item-line"); - if (inputs[id]) { - inputsBox[id].style.borderColor = "#EBEBEB"; - label[id].style.transform = "translate(-10px,-27px)"; - label[id].style.color = "#959595"; - inputs[id].style.backgroundColor = "#fff"; - line[id].style.backgroundColor = "#fff"; - } + inputs[id].style.borderColor = "#df1452"; + inputs[id].style.backgroundColor = "#fff"; + inputs[id].style.color = "#404040"; + label[id].style.transform = `translate(-10px,-27px)`; + label[id].style.color = "#df1452"; + line[id].style.backgroundColor = "#fff"; + }; - }; - const blurHandler2 = (id) => { - let inputsBox = document.querySelectorAll(".Login-box-form-item"); - let inputs = document.querySelectorAll(".Login-box-form-item-input"); - let label = document.querySelectorAll(".Login-box-form-item-label"); - let line = document.querySelectorAll(".Login-box-form-item-line"); - if (inputs[id]) { - inputsBox[id].style.borderColor = "#404040"; - label[id].style.transform = "translate(-10px,-27px)"; - label[id].style.color = "#404040"; - inputs[id].style.backgroundColor = "#fff"; - line[id].style.backgroundColor = "#fff"; - } - - }; - return ( -
-
-
- {title ? title : 'نام کاربری'} -
- {if(onFocus){onFocus();} focusHandler(id ? id : 0)}} - - - onBlur={() => blurHandler(id ? id : 0)} - onChange={onChange} - value={value} - maxLength={max} - - /> - -
- ) -} + const blurHandler = (id) => { + let inputsBox = document.querySelectorAll(".Login-box-form-item"); + let inputs = document.querySelectorAll(".Login-box-form-item-input"); + let label = document.querySelectorAll(".Login-box-form-item-label"); + let line = document.querySelectorAll(".Login-box-form-item-line"); + if (inputs[id]) { + inputsBox[id].style.borderColor = "#EBEBEB"; + label[id].style.transform = "translate(-10px,-27px)"; + label[id].style.color = "#959595"; + inputs[id].style.backgroundColor = "#fff"; + line[id].style.backgroundColor = "#fff"; + } + }; + const blurHandler2 = (id) => { + let inputsBox = document.querySelectorAll(".Login-box-form-item"); + let inputs = document.querySelectorAll(".Login-box-form-item-input"); + let label = document.querySelectorAll(".Login-box-form-item-label"); + let line = document.querySelectorAll(".Login-box-form-item-line"); + if (inputs[id]) { + inputsBox[id].style.borderColor = "#404040"; + label[id].style.transform = "translate(-10px,-27px)"; + label[id].style.color = "#404040"; + inputs[id].style.backgroundColor = "#fff"; + line[id].style.backgroundColor = "#fff"; + } + }; + return ( +
+
+
+ {title ? title : "نام کاربری"} +
+ { + if (onFocus) { + onFocus(); + } + focusHandler(id ? id : 0); + }} + onBlur={() => blurHandler(id ? id : 0)} + onChange={onChange} + value={value} + maxLength={max} + /> +
+ ); +}; export default Input; \ No newline at end of file diff --git a/src/view/register/index.js b/src/view/register/index.js index bc183f3..9e45d2a 100644 --- a/src/view/register/index.js +++ b/src/view/register/index.js @@ -536,6 +536,7 @@ const Register = ({ direction="rtl" id={0} value={userInfo?.firstName} + defaultValue={user?.firstName} onChange={(e) => setUserInfo({ ...userInfo, @@ -550,6 +551,7 @@ const Register = ({ id={1} direction="rtl" value={userInfo.lastName} + defaultValue={user?.lastName} onChange={(e) => setUserInfo({ ...userInfo, @@ -566,6 +568,7 @@ const Register = ({ type="textNumber" max={10} value={userInfo.nationalId} + defaultValue={user?.nationalId} onChange={(e) => setUserInfo({ ...userInfo, @@ -608,6 +611,7 @@ const Register = ({ setUserInfo({ ...userInfo, gender: e.target.value }) } className="bg-white border border-solid border-gray-200 w-52 px-3 mx-1 rounded text-black outline-red52 py-1 h-12 mt-6" + style={user?.gender ? { pointerEvents: "none" } : null} > {genders.map((item) => ( {grades.map((item) => (