From a1ca7bff4d4610c30a2083409c8978ef132901c8 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Mon, 11 Dec 2023 17:37:39 +0530 Subject: [PATCH] code refactoring --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/CustomInput/CustomInput.tsx | 28 +++++++++++++++----------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index f76d1b253..9c1d62d24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.0.45-beta-10", + "version": "0.0.45-beta-11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.0.45-beta-10", + "version": "0.0.45-beta-11", "license": "ISC", "dependencies": { "sass": "^1.56.2", diff --git a/package.json b/package.json index 2b1961de9..cfaabd96c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.0.45-beta-10", + "version": "0.0.45-beta-11", "description": "Supporting common component library", "main": "dist/index.js", "scripts": { diff --git a/src/Common/CustomInput/CustomInput.tsx b/src/Common/CustomInput/CustomInput.tsx index 2d00b4b64..f83422ba0 100644 --- a/src/Common/CustomInput/CustomInput.tsx +++ b/src/Common/CustomInput/CustomInput.tsx @@ -28,7 +28,6 @@ export function CustomInput({ state, handleBlurChange }: CustomInputProps) { - const [stateForm, setStateForm] = useState(state) const renderLabelHelperText = () => { return ( @@ -53,17 +52,22 @@ export function CustomInput({ } const handleOnBlur = (event) => { - if(typeof handleBlurChange === 'function') { - handleBlurChange(event) - } - console.log('event', event) - - if (stateForm) { - console.log('stateForm', stateForm) - setStateForm((prevState) => ({ - ...prevState, - [event.target.name]: event.target.value.trim(), - })) + + onChange({ + ...event, + target: { + ...event.target, + value: event.target.value.trim(), + }, + }) + if (typeof handleBlurChange === 'function') { + handleBlurChange({ + ...event, + target: { + ...event.target, + value: event.target.value.trim(), + }, + }) } }