From 44ffb0e0e40091d1ecabad16b030806269c35847 Mon Sep 17 00:00:00 2001 From: bicochan Date: Thu, 29 May 2025 13:35:12 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20number=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=9D=B8=ED=92=8B=20onChange=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cs/src/pages/bbs/ui/bbs-form.tsx | 20 ++++--------- apps/cs/src/pages/image/ui/image-form.tsx | 8 ++---- apps/cs/src/pages/module/ui/module-form.tsx | 8 ++---- apps/cs/src/pages/popup/ui/popup-form.tsx | 32 ++++++++------------- 4 files changed, 24 insertions(+), 44 deletions(-) diff --git a/apps/cs/src/pages/bbs/ui/bbs-form.tsx b/apps/cs/src/pages/bbs/ui/bbs-form.tsx index 8f645da1e..b472073db 100644 --- a/apps/cs/src/pages/bbs/ui/bbs-form.tsx +++ b/apps/cs/src/pages/bbs/ui/bbs-form.tsx @@ -189,13 +189,9 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) { type="number" min={0} value={boardTemplate?.atflMaxCnt ?? field.value ?? ""} - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange( - value === "" ? null : parseInt(value), - ); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } className="w-[12rem] !text-[1.3rem]" placeholder="최대 개수 입력" disabled={ @@ -224,13 +220,9 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) { value={ boardTemplate?.atflMaxFileSz ?? field.value ?? "" } - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange( - value === "" ? null : parseInt(value), - ); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } className="w-[12rem] !text-[1.3rem]" placeholder="최대 크기 입력" disabled={ diff --git a/apps/cs/src/pages/image/ui/image-form.tsx b/apps/cs/src/pages/image/ui/image-form.tsx index af0e8f976..0368ace33 100644 --- a/apps/cs/src/pages/image/ui/image-form.tsx +++ b/apps/cs/src/pages/image/ui/image-form.tsx @@ -124,11 +124,9 @@ function ImageForm({ form, imgSn, ...props }: ImageFormProps) { type="number" min={0} value={field.value ?? ""} - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange(parseInt(value)); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } className="w-[12rem] !text-[1.3rem]" placeholder="정렬순서 입력" /> diff --git a/apps/cs/src/pages/module/ui/module-form.tsx b/apps/cs/src/pages/module/ui/module-form.tsx index 8ee685407..2615fe40b 100644 --- a/apps/cs/src/pages/module/ui/module-form.tsx +++ b/apps/cs/src/pages/module/ui/module-form.tsx @@ -113,11 +113,9 @@ function ModuleForm({ form, authorizationNo, ...props }: BannerFormProps) { type="number" min={0} value={field.value ?? ""} - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange(parseInt(value)); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } className="w-[12rem] !text-[1.3rem]" placeholder="정렬순서 입력" /> diff --git a/apps/cs/src/pages/popup/ui/popup-form.tsx b/apps/cs/src/pages/popup/ui/popup-form.tsx index 6ab790ac4..eea86c7b0 100644 --- a/apps/cs/src/pages/popup/ui/popup-form.tsx +++ b/apps/cs/src/pages/popup/ui/popup-form.tsx @@ -116,11 +116,9 @@ function PopupForm({ value={field.value ?? 0} className="w-[10rem] !text-[1.3rem]" placeholder="너비" - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange(parseInt(value)); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } /> @@ -139,11 +137,9 @@ function PopupForm({ value={field.value ?? 0} className="w-[10rem] !text-[1.3rem]" placeholder="높이" - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange(parseInt(value)); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } /> @@ -168,11 +164,9 @@ function PopupForm({ value={field.value ?? 0} className="w-[10rem] !text-[1.3rem]" placeholder="Left" - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange(parseInt(value)); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } /> @@ -191,11 +185,9 @@ function PopupForm({ value={field.value ?? 0} className="w-[10rem] !text-[1.3rem]" placeholder="Top" - onChange={(e) => { - const value = e.target.value; - if (isNaN(parseInt(value))) return; - field.onChange(parseInt(value)); - }} + onChange={(e) => + field.onChange(parseInt(e.target.value)) + } />