+
@@ -130,13 +107,17 @@ function BusinessCostFormSection() {
const diff = (data.tstmDesignAmt || 0) - (data.bgtRfltAmt || 0);
const paddingLeft = `${item.level * 1.6}rem`;
- const showSubIcon = item.level >= 3;
+ const showSubIcon = item.level >= 2;
return (
- {showSubIcon && └}
- {item.label}
+
+ {showSubIcon && (
+ └
+ )}
+ {item.label}
+
-
- {calculateDiffPercent(diff, data.bgtRfltAmt || 0)}
-
+ {calcDiffPercent(diff, data.bgtRfltAmt || 0)}
);
diff --git a/apps/as/src/pages/instl-sncn/ui/sections/business-scale-form-section.tsx b/apps/as/src/widgets/pbadms-sprt/ui/business-scale-form-section.tsx
similarity index 57%
rename from apps/as/src/pages/instl-sncn/ui/sections/business-scale-form-section.tsx
rename to apps/as/src/widgets/pbadms-sprt/ui/business-scale-form-section.tsx
index f9d14f92f..63698dd08 100644
--- a/apps/as/src/pages/instl-sncn/ui/sections/business-scale-form-section.tsx
+++ b/apps/as/src/widgets/pbadms-sprt/ui/business-scale-form-section.tsx
@@ -1,12 +1,13 @@
"use client";
-import { useEffect } from "react";
+import { useEffect, useMemo } from "react";
import { Controller, useFormContext, useWatch } from "react-hook-form";
import { Field } from "@/shared/ui/field";
-import { useCnstpSeMngPage } from "@/entities/cnstp";
+import { useCnstpSeMngTree } from "@/entities/cnstp";
import {
Input,
+ Skeleton,
Table,
TableBody,
TableCell,
@@ -15,57 +16,68 @@ import {
TableRow,
} from "@common/components";
-import type { CnfmRegistFormData } from "../../lib/cnfm-regist-schema";
-import { SectionCollapsible } from "../components/section-collapsible";
+import { buildCnstpScaleItems, recalculateBzScaleTotals } from "../lib/business-scale-form-utils";
+
+import { SectionCollapsible } from "./section-collapsible";
+
+interface BusinessScaleFormData {
+ bzScaleList: Array<{
+ cnstpSeCd: string;
+ bscPl: number;
+ budgetReflct: number;
+ thtiDsgn: number;
+ diff?: number;
+ }>;
+}
type ScaleFieldKey = "bscPl" | "budgetReflct" | "thtiDsgn";
function BusinessScaleFormSection() {
- const { control, setValue, getValues } = useFormContext
();
+ const { control, setValue, getValues } = useFormContext();
const bzScaleList = useWatch({ control, name: "bzScaleList" }) ?? [];
- const { data: cnstpSeList } = useCnstpSeMngPage({ useYn: "Y" });
+ const { data: cnstpTree = [] } = useCnstpSeMngTree();
- const cnstpItems =
- cnstpSeList?.content?.map((item) => ({
- code: item.cnstpSeCd,
- label: item.cnstpSeCdNm,
- })) ?? [];
+ const scaleItems = useMemo(() => buildCnstpScaleItems(cnstpTree), [cnstpTree]);
useEffect(() => {
- if (!cnstpSeList?.content?.length) return;
+ if (scaleItems.length === 0) return;
const existingMap = new Map(getValues("bzScaleList").map((item) => [item.cnstpSeCd, item]));
- setValue(
- "bzScaleList",
- cnstpSeList.content.map((item) => {
- const existing = existingMap.get(item.cnstpSeCd);
- if (existing) return existing;
+ const next = scaleItems.map((item) => {
+ const existing = existingMap.get(item.code);
+ if (existing) return existing;
- return {
- cnstpSeCd: item.cnstpSeCd,
- bscPl: 0,
- budgetReflct: 0,
- thtiDsgn: 0,
- diff: 0,
- };
- }),
- );
- }, [cnstpSeList?.content, getValues, setValue]);
+ return {
+ cnstpSeCd: item.code,
+ bscPl: 0,
+ budgetReflct: 0,
+ thtiDsgn: 0,
+ diff: 0,
+ };
+ });
+
+ setValue("bzScaleList", recalculateBzScaleTotals(next, scaleItems));
+ }, [scaleItems, getValues, setValue]);
function handleScaleChange(index: number, fieldKey: ScaleFieldKey, value: string) {
const numValue = Number(value) || 0;
- const list = getValues("bzScaleList");
- const updated = { ...list[index], [fieldKey]: numValue };
+ const draft = [...getValues("bzScaleList")];
+ draft[index] = { ...draft[index], [fieldKey]: numValue };
+ const next = recalculateBzScaleTotals(draft, scaleItems);
+ setValue("bzScaleList", next, { shouldDirty: true });
+ }
- if (fieldKey === "budgetReflct" || fieldKey === "thtiDsgn") {
- updated.diff = updated.thtiDsgn - updated.budgetReflct;
- }
-
- const newList = [...list];
- newList[index] = updated;
- setValue("bzScaleList", newList);
+ if (scaleItems.length === 0) {
+ return (
+
+
+
+
+
+
+ );
}
return (
@@ -82,13 +94,24 @@ function BusinessScaleFormSection() {
- {cnstpItems.map((item, idx) => {
+ {scaleItems.map((item, idx) => {
const data = bzScaleList[idx];
if (!data) return null;
+ const diff = data.diff ?? 0;
+ const paddingLeft = `${item.level * 1.6}rem`;
+ const showSubIcon = item.level >= 2;
+
return (
- {item.label}
+
+
+ {showSubIcon && (
+ └
+ )}
+ {item.label}
+
+
handleScaleChange(idx, "bscPl", e.target.value)}
+ readOnly={item.readonly}
aria-invalid={fieldState.invalid}
- className="text-right"
+ className={`text-right ${item.readonly ? "bg-muted" : ""}`}
/>
)}
@@ -116,8 +140,9 @@ function BusinessScaleFormSection() {
type="number"
value={field.value || ""}
onChange={(e) => handleScaleChange(idx, "budgetReflct", e.target.value)}
+ readOnly={item.readonly}
aria-invalid={fieldState.invalid}
- className="text-right"
+ className={`text-right ${item.readonly ? "bg-muted" : ""}`}
/>
)}
@@ -133,8 +158,9 @@ function BusinessScaleFormSection() {
type="number"
value={field.value || ""}
onChange={(e) => handleScaleChange(idx, "thtiDsgn", e.target.value)}
+ readOnly={item.readonly}
aria-invalid={fieldState.invalid}
- className="text-right"
+ className={`text-right ${item.readonly ? "bg-muted" : ""}`}
/>
)}
@@ -142,9 +168,7 @@ function BusinessScaleFormSection() {
- {data.diff > 0
- ? `+${data.diff.toLocaleString()}`
- : data.diff.toLocaleString()}
+ {diff > 0 ? `+${diff.toLocaleString()}` : diff.toLocaleString()}
diff --git a/apps/as/src/pages/instl-sncn/ui/sections/checklist-form-section.tsx b/apps/as/src/widgets/pbadms-sprt/ui/checklist-form-section.tsx
similarity index 81%
rename from apps/as/src/pages/instl-sncn/ui/sections/checklist-form-section.tsx
rename to apps/as/src/widgets/pbadms-sprt/ui/checklist-form-section.tsx
index 3886be20f..82386ab06 100644
--- a/apps/as/src/pages/instl-sncn/ui/sections/checklist-form-section.tsx
+++ b/apps/as/src/widgets/pbadms-sprt/ui/checklist-form-section.tsx
@@ -25,36 +25,33 @@ import {
TabsTrigger,
} from "@common/components";
-import { orderCklstTreeNodes, syncCklstResultListFromTree } from "../../lib/checklist-form-utils";
-import type { CnfmRegistFormData } from "../../lib/cnfm-regist-schema";
-import { SectionCollapsible } from "../components/section-collapsible";
+import { buildChecklistTabs, syncCklstResultListFromTree } from "../lib/checklist-form-utils";
-interface ChecklistFormSectionProps {
- docSeComCd: string;
-}
+import { SectionCollapsible } from "./section-collapsible";
-interface ChecklistItem {
+type FieldPrefix = "fnrsCnsltnMng" | "instlSncnMng";
+
+interface CklstResultListItem {
cklstSn: number;
cklstArtclSn: number;
cklstRvwSn: number;
rvwStpComCd: string;
- title: string;
- content: string;
- bchckUseYn: "Y" | "N";
- treeLevel: number;
+ selected: "Y" | "N" | null;
+ picRvwCn?: string | null;
}
-interface ChecklistTab {
- code: string;
- label: string;
- items: ChecklistItem[];
+interface ChecklistFormSectionProps {
+ docSeComCd: string;
+ fieldPrefix: FieldPrefix;
}
-function ChecklistFormSection({ docSeComCd }: ChecklistFormSectionProps) {
- const { watch, setValue, control, getValues } = useFormContext();
+function ChecklistFormSection({ docSeComCd, fieldPrefix }: ChecklistFormSectionProps) {
+ const { watch, setValue, control, getValues } = useFormContext();
const [activeTab, setActiveTab] = useState("");
- const taskSeComCdArray = watch("instlSncnMng.taskSeComCd");
- const cklstResultList = useWatch({ control, name: "cklstResultList" }) ?? [];
+ const taskSeComCd = watch(`${fieldPrefix}.taskSeComCd`) as string[] | undefined;
+ const taskSeComCdArray = useMemo(() => taskSeComCd ?? [], [taskSeComCd]);
+ const cklstResultList =
+ (useWatch({ control, name: "cklstResultList" }) as CklstResultListItem[] | undefined) ?? [];
const cklstRvwSnIndexMap = useMemo(
() => new Map(cklstResultList.map((item, index) => [item.cklstRvwSn, index])),
@@ -74,7 +71,7 @@ function ChecklistFormSection({ docSeComCd }: ChecklistFormSectionProps) {
const { data: cklstTree = [], isLoading: isLoadingCklstTree } = useQuery({
queryKey: ["cklstTree", docSeComCd, taskSeComCdArray],
queryFn: async () => {
- const codes = (taskSeComCdArray || []).filter(Boolean);
+ const codes = (taskSeComCdArray || []).filter(Boolean) as string[];
if (codes.length === 0) return [];
const results = await Promise.all(
@@ -100,34 +97,10 @@ function ChecklistFormSection({ docSeComCd }: ChecklistFormSectionProps) {
staleTime: Infinity,
});
- const checklistTabs = useMemo((): ChecklistTab[] => {
- if (cklstTree.length === 0) return [];
-
- const grouped = new Map();
- cklstTree.forEach((node) => {
- const taskCode = node.taskSeComCd ?? "";
- if (!taskCode) return;
- if (!grouped.has(taskCode)) grouped.set(taskCode, []);
- grouped.get(taskCode)!.push(node);
- });
-
- const orderedCodes = (taskSeComCdArray || []).filter((code) => grouped.has(code));
-
- return orderedCodes.map((code) => ({
- code,
- label: taskCodeLabels[code] || code,
- items: orderCklstTreeNodes(grouped.get(code)!).map((node) => ({
- cklstSn: node.cklstSn,
- cklstArtclSn: node.cklstArtclSn,
- cklstRvwSn: node.cklstRvwSn,
- rvwStpComCd: "LOCAL",
- title: node.cklstArtclNm,
- content: node.rvwCn,
- bchckUseYn: node.bchckUseYn,
- treeLevel: node.treeLevel,
- })),
- }));
- }, [cklstTree, taskCodeLabels, taskSeComCdArray]);
+ const checklistTabs = useMemo(
+ () => buildChecklistTabs(cklstTree, taskSeComCdArray, taskCodeLabels),
+ [cklstTree, taskCodeLabels, taskSeComCdArray],
+ );
useEffect(() => {
if (isLoadingCklstTree) return;
@@ -263,12 +236,13 @@ function ChecklistFormSection({ docSeComCd }: ChecklistFormSectionProps) {
style={{
paddingLeft: `${Math.max(0, item.treeLevel - 1) * 16 + 8}px`,
}}
+ colSpan={showRadios ? 0 : 2}
>
{item.treeLevel > 1 ? "└ " : ""}
{item.content}
-
- {showRadios && resultIdx >= 0 ? (
+ {showRadios && resultIdx >= 0 ? (
+
)}
/>
- ) : null}
-
+
+ ) : null}
);
})}
diff --git a/apps/as/src/pages/instl-sncn/ui/sections/contact-info-form-section.tsx b/apps/as/src/widgets/pbadms-sprt/ui/contact-info-form-section.tsx
similarity index 86%
rename from apps/as/src/pages/instl-sncn/ui/sections/contact-info-form-section.tsx
rename to apps/as/src/widgets/pbadms-sprt/ui/contact-info-form-section.tsx
index 17b4bfcba..7787f7a40 100644
--- a/apps/as/src/pages/instl-sncn/ui/sections/contact-info-form-section.tsx
+++ b/apps/as/src/widgets/pbadms-sprt/ui/contact-info-form-section.tsx
@@ -4,13 +4,17 @@ import { Controller, useFormContext } from "react-hook-form";
import { useUserStore } from "@/shared/lib";
import { Field, FieldError } from "@/shared/ui/field";
+import { SectionCollapsible } from "@/widgets/pbadms-sprt";
import { Input, Table, TableCell, TableHead, TableHeader, TableRow } from "@common/components";
-import type { CnfmRegistFormData } from "../../lib/cnfm-regist-schema";
-import { SectionCollapsible } from "../components/section-collapsible";
+type FieldPrefix = "fnrsCnsltnMng" | "instlSncnMng";
-function ContactInfoFormSection() {
- const { control } = useFormContext();
+interface ContactInfoFormSectionProps {
+ fieldPrefix: FieldPrefix;
+}
+
+function ContactInfoFormSection({ fieldPrefix }: ContactInfoFormSectionProps) {
+ const { control } = useFormContext();
const userInfo = useUserStore((state) => state.userInfo);
return (
@@ -39,7 +43,7 @@ function ContactInfoFormSection() {
이름
(
@@ -57,7 +61,7 @@ function ContactInfoFormSection() {
연락처
(
@@ -77,7 +81,7 @@ function ContactInfoFormSection() {
소속
(
@@ -95,7 +99,7 @@ function ContactInfoFormSection() {
이메일
(
diff --git a/apps/as/src/pages/instl-sncn/ui/sections/privacy-consent-section.tsx b/apps/as/src/widgets/pbadms-sprt/ui/privacy-consent-section.tsx
similarity index 94%
rename from apps/as/src/pages/instl-sncn/ui/sections/privacy-consent-section.tsx
rename to apps/as/src/widgets/pbadms-sprt/ui/privacy-consent-section.tsx
index f25014bdf..d51d9aeef 100644
--- a/apps/as/src/pages/instl-sncn/ui/sections/privacy-consent-section.tsx
+++ b/apps/as/src/widgets/pbadms-sprt/ui/privacy-consent-section.tsx
@@ -13,11 +13,14 @@ import {
TableRow,
} from "@common/components";
-import type { CnfmRegistFormData } from "../../lib/cnfm-regist-schema";
-import { SectionCollapsible } from "../components/section-collapsible";
+import { SectionCollapsible } from "./section-collapsible";
+
+interface PrivacyConsentFormData {
+ privacyConsent: "Y" | "N";
+}
function PrivacyConsentSection() {
- const { control } = useFormContext();
+ const { control } = useFormContext();
return (
diff --git a/apps/as/src/pages/instl-sncn/ui/components/section-collapsible.tsx b/apps/as/src/widgets/pbadms-sprt/ui/section-collapsible.tsx
similarity index 100%
rename from apps/as/src/pages/instl-sncn/ui/components/section-collapsible.tsx
rename to apps/as/src/widgets/pbadms-sprt/ui/section-collapsible.tsx
diff --git a/apps/as/src/pages/instl-sncn/ui/components/task-se-picker-dialog.tsx b/apps/as/src/widgets/pbadms-sprt/ui/task-se-picker-dialog.tsx
similarity index 88%
rename from apps/as/src/pages/instl-sncn/ui/components/task-se-picker-dialog.tsx
rename to apps/as/src/widgets/pbadms-sprt/ui/task-se-picker-dialog.tsx
index b1a4fd135..10fcc2b81 100644
--- a/apps/as/src/pages/instl-sncn/ui/components/task-se-picker-dialog.tsx
+++ b/apps/as/src/widgets/pbadms-sprt/ui/task-se-picker-dialog.tsx
@@ -24,11 +24,19 @@ interface TaskSePickerDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onConfirm: (selectedCodes: string[]) => void;
+ title: string;
+ codeUpCd?: string;
}
-function TaskSePickerDialog({ open, onOpenChange, onConfirm }: TaskSePickerDialogProps) {
+function TaskSePickerDialog({
+ open,
+ onOpenChange,
+ onConfirm,
+ title,
+ codeUpCd,
+}: TaskSePickerDialogProps) {
const [selectedCodes, setSelectedCodes] = useState([]);
- const { data: taskOptions, isPending } = useCodeList("INSTL");
+ const { data: taskOptions, isPending } = useCodeList(codeUpCd);
useEffect(() => {
if (!open) return;
@@ -49,7 +57,7 @@ function TaskSePickerDialog({ open, onOpenChange, onConfirm }: TaskSePickerDialo