feat: 공통코드 등록 팝업에서 분류코드를 뺀다
기획에서 빠진 항목이다. 저장되는 값이 아니라 코드ID 앞 3자를 채워 주는 입력 보조였고(백엔드에 해당 컬럼이 없다), 셀렉트와 함께 접두사 상수·헬퍼도 지운다 — 쓰는 곳이 이 팝업뿐이었다. Co-Authored-By: Claude Opus 5
@6e89140c3bd5cd6538a971bc0280c99106b0de4a
--- app/(protected)/(basic)/system/codes/_components/code-group-modal.tsx
+++ app/(protected)/(basic)/system/codes/_components/code-group-modal.tsx
... | ... | @@ -5,15 +5,8 @@ |
| 5 | 5 |
import { FoxHelperText } from '@fox/core/components/fox-helper-text';
|
| 6 | 6 |
import { FoxInput } from '@fox/core/components/fox-input';
|
| 7 | 7 |
import { FoxModal } from '@fox/core/components/fox-modal';
|
| 8 |
-import { FoxSelect } from '@fox/core/components/fox-select';
|
|
| 9 | 8 |
import { useFeedback } from '@/app/_hooks/use-feedback';
|
| 10 |
-import {
|
|
| 11 |
- CODE_ID_PREFIXES, |
|
| 12 |
- DEFAULT_CODE_ID_PREFIX, |
|
| 13 |
- applyCodeIdPrefix, |
|
| 14 |
- readCodeIdPrefix, |
|
| 15 |
- type CommonCodeGroup, |
|
| 16 |
-} from '@/lib/domain/common-code'; |
|
| 9 |
+import { type CommonCodeGroup } from '@/lib/domain/common-code';
|
|
| 17 | 10 |
import { INITIAL_COMMON_CODE_FORM_STATE } from '@/lib/domain/common-code-form';
|
| 18 | 11 |
import { createCodeGroupAction, updateCodeGroupAction } from '../_actions';
|
| 19 | 12 |
import styles from './code-form.module.scss'; |
... | ... | @@ -29,10 +22,7 @@ |
| 29 | 22 |
* 공통코드 등록/수정 팝업 — 기획 1842:16056 / 1842:16122. |
| 30 | 23 |
* |
| 31 | 24 |
* 두 팝업은 제목·버튼 글자와 **코드ID의 읽기 전용 여부**만 다르고 입력 항목이 같아 한 조각으로 둔다. |
| 32 |
- * |
|
| 33 |
- * **분류코드는 저장되지 않는다.** `TB_SYS_COM_CD`에 해당 컬럼이 없어(확인함) 이 셀렉트는 코드ID |
|
| 34 |
- * 접두사를 채워 주는 입력 보조로만 동작한다 — 시안 목록이 전부 `CMS004`처럼 접두사 3자 + 일련번호라 |
|
| 35 |
- * 그 작명 규칙을 화면이 거드는 것이다(사용자 확정 사항). 저장되는 값은 코드ID 하나다. |
|
| 25 |
+ |
|
| 36 | 26 |
* |
| 37 | 27 |
* 저장 버튼은 foot 슬롯에 그려져 폼의 자손이 아니다 — ref로 직접 제출한다(다른 팝업과 같은 방식). |
| 38 | 28 |
*/ |
... | ... | @@ -46,9 +36,6 @@ |
| 46 | 36 |
); |
| 47 | 37 |
|
| 48 | 38 |
const [comCd, setComCd] = useState(group?.comCd ?? ''); |
| 49 |
- const [prefix, setPrefix] = useState( |
|
| 50 |
- group ? readCodeIdPrefix(group.comCd) : DEFAULT_CODE_ID_PREFIX |
|
| 51 |
- ); |
|
| 52 | 39 |
|
| 53 | 40 |
useEffect(() => {
|
| 54 | 41 |
if (state.status === 'success') {
|
... | ... | @@ -102,25 +89,6 @@ |
| 102 | 89 |
maxLength={50}
|
| 103 | 90 |
/> |
| 104 | 91 |
</div> |
| 105 |
- |
|
| 106 |
- {!isEdit && (
|
|
| 107 |
- <div className={styles.field}>
|
|
| 108 |
- <FoxSelect |
|
| 109 |
- size="md" |
|
| 110 |
- label="분류코드" |
|
| 111 |
- options={CODE_ID_PREFIXES.map((value) => ({
|
|
| 112 |
- value, |
|
| 113 |
- label: value, |
|
| 114 |
- }))} |
|
| 115 |
- value={prefix}
|
|
| 116 |
- onValueChange={(next) => {
|
|
| 117 |
- setPrefix(next); |
|
| 118 |
- setComCd((current) => applyCodeIdPrefix(current, next)); |
|
| 119 |
- }} |
|
| 120 |
- hint="코드ID 앞에 붙는 분류입니다. 별도로 저장되지 않습니다." |
|
| 121 |
- /> |
|
| 122 |
- </div> |
|
| 123 |
- )} |
|
| 124 | 92 |
|
| 125 | 93 |
<div className={styles.field}>
|
| 126 | 94 |
<FoxInput |
--- lib/domain/common-code.ts
+++ lib/domain/common-code.ts
... | ... | @@ -39,9 +39,7 @@ |
| 39 | 39 |
/** |
| 40 | 40 |
* 공통코드(그룹) — 시안의 "공통코드 목록" 한 줄. |
| 41 | 41 |
* |
| 42 |
- * `TB_SYS_COM_CD`의 컬럼은 이 셋이 전부다(+감사 컬럼). 시안 등록 팝업의 "분류코드"에 |
|
| 43 |
- * 해당하는 컬럼은 **없다** — 그 셀렉트는 코드ID 접두사를 채워 주는 입력 보조일 뿐이고 |
|
| 44 |
- * 저장되는 값은 `comCd` 하나다(사용자 확정 사항). |
|
| 42 |
+ * `TB_SYS_COM_CD`의 컬럼은 이 셋이 전부다(+감사 컬럼). |
|
| 45 | 43 |
*/ |
| 46 | 44 |
export type CommonCodeGroup = {
|
| 47 | 45 |
/** 백엔드 `comCd` — PK이자 화면의 "코드ID". 상세코드를 묶는 키다. */ |
... | ... | @@ -74,36 +72,6 @@ |
| 74 | 72 |
/** 백엔드 `frstRegDtStr` — `YYYY-MM-DD`. */ |
| 75 | 73 |
createdAt: string | null; |
| 76 | 74 |
}; |
| 77 |
- |
|
| 78 |
-/** |
|
| 79 |
- * 코드ID 접두사(시안의 "분류코드") — 저장되는 값이 아니라 코드ID를 지을 때의 작명 규칙이다. |
|
| 80 |
- * 시안 목록이 전부 `CMS004`처럼 접두사 3자 + 일련번호라 그 규칙을 화면이 거들게 한다. |
|
| 81 |
- * |
|
| 82 |
- * 백엔드에 분류 컬럼이 생기면 이 상수 대신 그 코드 목록을 쓰면 된다. |
|
| 83 |
- */ |
|
| 84 |
-export const CODE_ID_PREFIXES: readonly string[] = ['CMS', 'SYS', 'FSC', 'CST']; |
|
| 85 |
- |
|
| 86 |
-export const DEFAULT_CODE_ID_PREFIX = CODE_ID_PREFIXES[0]; |
|
| 87 |
- |
|
| 88 |
-/** |
|
| 89 |
- * 코드ID에서 접두사를 읽는다 — 앞 3자가 아는 접두사면 그것을, 아니면 기본값을 돌려준다. |
|
| 90 |
- * 수정 팝업이 기존 코드ID로 셀렉트의 초기값을 정할 때 쓴다. |
|
| 91 |
- */ |
|
| 92 |
-export function readCodeIdPrefix(comCd: string): string {
|
|
| 93 |
- const head = comCd.slice(0, 3).toUpperCase(); |
|
| 94 |
- return CODE_ID_PREFIXES.includes(head) ? head : DEFAULT_CODE_ID_PREFIX; |
|
| 95 |
-} |
|
| 96 |
- |
|
| 97 |
-/** |
|
| 98 |
- * 접두사를 바꿔 끼운 코드ID를 만든다. 기존 값이 아는 접두사로 시작하면 그 자리를 갈아 끼우고, |
|
| 99 |
- * 아니면 앞에 덧붙인다 — 사용자가 이미 적어 둔 일련번호를 지우지 않기 위해서다. |
|
| 100 |
- */ |
|
| 101 |
-export function applyCodeIdPrefix(comCd: string, prefix: string): string {
|
|
| 102 |
- const rest = CODE_ID_PREFIXES.includes(comCd.slice(0, 3).toUpperCase()) |
|
| 103 |
- ? comCd.slice(3) |
|
| 104 |
- : comCd; |
|
| 105 |
- return `${prefix}${rest}`;
|
|
| 106 |
-} |
|
| 107 | 75 |
|
| 108 | 76 |
export function formatOptionalText(value: string | null | undefined): string {
|
| 109 | 77 |
return value === null || value === undefined || value === '' |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?