[as] chore: 행정지원 숫자 폼 음수 입력 제한

This commit is contained in:
2026-10-02 15:14:22 +09:00
parent 9334514c71
commit 85f535eb5d
12 changed files with 72 additions and 9 deletions
@@ -3,6 +3,7 @@
import { useEffect, useMemo } from "react";
import { useFormContext, useWatch } from "react-hook-form";
import { NON_NEGATIVE_INPUT_PROPS, stripMinusSign } from "@/shared/lib";
import { SectionCollapsible } from "@/shared/ui";
import { Field } from "@/shared/ui/field";
import { useAcntgSeMngTree } from "@/entities/acntg";
@@ -79,7 +80,7 @@ function BusinessCostFormSection() {
}, [costItems, getValues, setValue]);
function handleCostChange(index: number, fieldKey: CostFieldKey, value: string) {
const numValue = Number(truncateDecimals(value, COST_DECIMAL_PLACES)) || 0;
const numValue = Number(truncateDecimals(stripMinusSign(value), COST_DECIMAL_PLACES)) || 0;
const draft = [...getValues("bizCstList")];
draft[index] = { ...draft[index], [fieldKey]: numValue };
const next = recalculateBizCstTotals(draft, costItems);
@@ -102,6 +103,14 @@ function BusinessCostFormSection() {
<div className="overflow-x-auto">
<p className="mb-2 text-right font-normal text-muted-foreground">(단위: 백만원)</p>
<Table variant="secondary" className="table-fixed">
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="10%" />
<col width="10%" />
</colgroup>
<TableHeader>
<TableRow>
<TableHead className="w-[30rem]" rowSpan={2}>
@@ -143,6 +152,7 @@ function BusinessCostFormSection() {
<TableCell key={fieldKey}>
<Field>
<Input
{...NON_NEGATIVE_INPUT_PROPS}
type="number"
step={COST_STEP}
value={data[fieldKey] ?? ""}
@@ -3,6 +3,7 @@
import { useEffect, useMemo } from "react";
import { useFormContext, useWatch } from "react-hook-form";
import { NON_NEGATIVE_INPUT_PROPS, stripMinusSign } from "@/shared/lib";
import { SectionCollapsible } from "@/shared/ui";
import { Field } from "@/shared/ui/field";
import { useCnstpSeMngTree } from "@/entities/cnstp";
@@ -77,7 +78,8 @@ function BusinessScaleFormSection() {
function handleScaleChange(index: number, fieldKey: ScaleFieldKey, value: string) {
const item = scaleItems[index];
const normalized = item?.numYn ? truncateDecimals(value, item.dcptUnitCnt) : value;
const unsigned = stripMinusSign(value);
const normalized = item?.numYn ? truncateDecimals(unsigned, item.dcptUnitCnt) : unsigned;
const numValue = Number(normalized) || 0;
const draft = [...getValues("bzScaleList")];
draft[index] = { ...draft[index], [fieldKey]: numValue };
@@ -100,6 +102,13 @@ function BusinessScaleFormSection() {
<SectionCollapsible title="사업규모">
<div className="overflow-x-auto">
<Table variant="secondary">
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<TableHeader>
<TableRow>
<TableHead className="w-[30rem]">구분</TableHead>
@@ -132,6 +141,7 @@ function BusinessScaleFormSection() {
<TableCell key={fieldKey}>
<Field>
<Input
{...(item.numYn ? NON_NEGATIVE_INPUT_PROPS : {})}
type={item.numYn ? "number" : "text"}
step={item.numYn ? item.step : undefined}
value={data[fieldKey] ?? ""}
@@ -3,7 +3,12 @@
import { useEffect, useMemo, useState } from "react";
import { useFormContext, useWatch } from "react-hook-form";
import { getDefaultFileKey, useTus } from "@/shared/lib";
import {
getDefaultFileKey,
NON_NEGATIVE_INPUT_PROPS,
stripMinusSign,
useTus,
} from "@/shared/lib";
import { AttachmentFileField, SectionCollapsible } from "@/shared/ui";
import { Field } from "@/shared/ui/field";
import { useAcntgSeMngTree } from "@/entities/acntg";
@@ -142,7 +147,7 @@ function FnrsSharFormSection({ initialSharTree, initialSharAtchFiles }: FnrsShar
if (fieldKey === "rmrkCn") {
draft[index] = { ...row, rmrkCn: value };
} else {
const numValue = Number(value) || 0;
const numValue = Number(stripMinusSign(value)) || 0;
draft[index] = { ...row, [fieldKey]: numValue };
}
@@ -236,6 +241,7 @@ function FnrsSharFormSection({ initialSharTree, initialSharAtchFiles }: FnrsShar
<TableCell>
<Field>
<Input
{...NON_NEGATIVE_INPUT_PROPS}
type="number"
value={data.exstnAmt ?? ""}
onChange={(e) => handleSharChange(idx, "exstnAmt", e.target.value)}
@@ -247,6 +253,7 @@ function FnrsSharFormSection({ initialSharTree, initialSharAtchFiles }: FnrsShar
<TableCell>
<Field>
<Input
{...NON_NEGATIVE_INPUT_PROPS}
type="number"
value={data.chgRqtAmt ?? ""}
onChange={(e) => handleSharChange(idx, "chgRqtAmt", e.target.value)}