[as] feat: 하수도기본계획 목록 페이지 구현
This commit is contained in:
@@ -13,6 +13,7 @@ export { buildCnstpScaleItems, recalculateBzScaleTotals } from "./lib/business-s
|
||||
export {
|
||||
buildChecklistTabs,
|
||||
isFormChecklistComplete,
|
||||
normalizeTaskSeComCdArray,
|
||||
syncCklstResultListFromTree,
|
||||
} from "./lib/checklist-form-utils";
|
||||
export type { FnrsSharItemDef, FnrsSharListItem } from "./lib/fnrs-shar-form-utils";
|
||||
|
||||
@@ -26,6 +26,17 @@ interface CklstResultListItem {
|
||||
picRvwCn?: string | null;
|
||||
}
|
||||
|
||||
export function normalizeTaskSeComCdArray(
|
||||
value: string | string[] | undefined | null,
|
||||
): string[] {
|
||||
if (!value) return [];
|
||||
if (Array.isArray(value)) return value.filter(Boolean);
|
||||
return value
|
||||
.split(",")
|
||||
.map((code) => code.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function groupCklstTreeByTaskSeComCd(cklstTree: CklstTreeNode[]): Map<string, CklstTreeNode[]> {
|
||||
const grouped = new Map<string, CklstTreeNode[]>();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
TabsTrigger,
|
||||
} from "@common/components";
|
||||
|
||||
import { buildChecklistTabs, syncCklstResultListFromTree } from "../lib/checklist-form-utils";
|
||||
import { buildChecklistTabs, normalizeTaskSeComCdArray, syncCklstResultListFromTree } from "../lib/checklist-form-utils";
|
||||
|
||||
import { SectionCollapsible } from "./section-collapsible";
|
||||
|
||||
@@ -48,8 +48,11 @@ interface ChecklistFormSectionProps {
|
||||
function ChecklistFormSection({ docSeComCd, fieldPrefix }: ChecklistFormSectionProps) {
|
||||
const { watch, setValue, control, getValues } = useFormContext();
|
||||
const [activeTab, setActiveTab] = useState("");
|
||||
const taskSeComCd = watch(`${fieldPrefix}.taskSeComCd`) as string[] | undefined;
|
||||
const taskSeComCdArray = useMemo(() => taskSeComCd ?? [], [taskSeComCd]);
|
||||
const taskSeComCd = watch(`${fieldPrefix}.taskSeComCd`) as string | string[] | undefined;
|
||||
const taskSeComCdArray = useMemo(
|
||||
() => normalizeTaskSeComCdArray(taskSeComCd),
|
||||
[taskSeComCd],
|
||||
);
|
||||
const cklstResultList =
|
||||
(useWatch({ control, name: "cklstResultList" }) as CklstResultListItem[] | undefined) ?? [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user