feat(WEB): 공사관리 리스트 공통화 및 캘린더/포맷터 기능 개선
공사관리 리스트 공통화: - 입찰/계약/견적/인수인계/이슈/품목/노무/현장/파트너/단가/기성/현장브리핑/구조검토/유틸리티/작업자현황 리스트 공통 포맷터 적용 - 중복 포맷팅 로직 제거 (-530줄) 캘린더 기능 개선: - CEODashboard CalendarSection 기능 확장 - ScheduleCalendar DayCell/MonthView/WeekView 개선 - ui/calendar 컴포넌트 기능 추가 유틸리티 개선: - date.ts 날짜 유틸 함수 추가 - formatAmount.ts 금액 포맷 함수 추가 신규 추가: - useListHandlers 훅 추가 - src/constants/ 디렉토리 추가 - 포맷터 공통화 계획 문서 추가 - SAM ERP/MES 정체성 분석 문서 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
40
src/hooks/useListHandlers.ts
Normal file
40
src/hooks/useListHandlers.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
/**
|
||||
* 리스트 페이지 공통 핸들러 Hook
|
||||
*
|
||||
* 리스트 페이지에서 반복되는 라우팅 핸들러를 공통화
|
||||
* - handleRowClick: 상세 보기 (mode=view)
|
||||
* - handleEdit: 수정 모드 (mode=edit)
|
||||
*
|
||||
* @example
|
||||
* const { handleRowClick, handleEdit } = useListHandlers<Contract>(
|
||||
* 'construction/project/contract'
|
||||
* );
|
||||
*
|
||||
* // 자동으로 /ko/ 접두사 추가
|
||||
* // handleRowClick(item) → /ko/construction/project/contract/{id}?mode=view
|
||||
* // handleEdit(item) → /ko/construction/project/contract/{id}?mode=edit
|
||||
*/
|
||||
export function useListHandlers<T extends { id: string }>(basePath: string) {
|
||||
const router = useRouter();
|
||||
|
||||
const handleRowClick = useCallback(
|
||||
(item: T) => {
|
||||
router.push(`/ko/${basePath}/${item.id}?mode=view`);
|
||||
},
|
||||
[router, basePath]
|
||||
);
|
||||
|
||||
const handleEdit = useCallback(
|
||||
(item: T) => {
|
||||
router.push(`/ko/${basePath}/${item.id}?mode=edit`);
|
||||
},
|
||||
[router, basePath]
|
||||
);
|
||||
|
||||
return { handleRowClick, handleEdit, router };
|
||||
}
|
||||
Reference in New Issue
Block a user