'use client'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { FoxButton } from '@fox/core/components/fox-button'; import { FoxHeadingGroup } from '@fox/core/components/fox-heading-group'; import { FoxListContainer, type FoxListColumn, } from '@fox/core/components/fox-list-container'; import { FoxPageHeader } from '@fox/core/components/fox-page-header'; import { useFeedback } from '@/app/_hooks/use-feedback'; import { useBlockingAction } from '@/app/_hooks/use-blocking-action'; import { formatOptionalText, type CommonCodeDetail, type CommonCodeGroup, } from '@/lib/domain/common-code'; import { COMMON_CODE_PAGE_SIZE, COMMON_CODE_SEARCH_FIELD_OPTIONS, buildCommonCodeHref, type CommonCodeQuery, type CommonCodeSearchField, } from '@/lib/domain/common-code-query'; import { deleteCodeDetailAction, deleteCodeGroupAction } from '../_actions'; import { CodeDetailModal } from './code-detail-modal'; import { CodeGroupModal } from './code-group-modal'; import { CodeRowActions } from './code-row-actions'; import styles from './code-management.module.scss'; interface CodeManagementProps { query: CommonCodeQuery; groups: CommonCodeGroup[]; groupTotalCount: number; groupPage: number; groupTotalPages: number; /** 화면이 실제로 보여주는 선택 — URL 값이 목록에 없으면 서버가 첫 행으로 바꿔 넘긴다. */ selectedComCd: string | null; details: CommonCodeDetail[]; detailTotalCount: number; detailPage: number; detailTotalPages: number; nextSortSeq: number; } /** * 설명 칸 — 한 줄로 줄이고 넘치면 말줄임한다(스타일 주석 참조). 잘린 글자를 읽을 방법이 * 있어야 하므로 전문을 `title`로 남긴다. */ function Truncated({ text }: { text: string | null }) { const value = formatOptionalText(text); return ( {value} ); } /** 어느 팝업이 열려 있는지. 한 번에 하나만 열린다. */ type OpenModal = | { kind: 'group-create' } | { kind: 'group-edit'; group: CommonCodeGroup } | { kind: 'detail-create' } | { kind: 'detail-edit'; detail: CommonCodeDetail } | null; /** * 코드관리 — 기획 SYS_COD_001, 시안 관리자페이지(QsFVFFUKGH68xAPVkF3SJ9) 5402:13399 * * 목록이 둘이지만 화면은 하나다. 좌측 공통코드를 **행 전체로 눌러** 고르면 우측 상세코드가 그 * 그룹으로 갱신된다(기획 ④) — 선택은 URL에 실리므로 갱신은 서버가 다시 그려 준다. * * 두 목록 모두 `FoxListContainer`를 쓰되 화면 제목은 위에서 한 번만 그린다(`FoxPageHeader`). * 패널 이름은 `FoxHeadingGroup`이다 — 화면에 여럿 설 수 있는 구역 제목이라 `