feat(WEB): 권한 관리 시스템 구현 및 상세 페이지 권한 통합
- PermissionContext, usePermission 훅, PermissionGuard 컴포넌트 신규 추가
- AccessDenied 접근 거부 페이지 추가
- permissions lib (체커, 매퍼, 타입) 구현
- BadDebtDetail, BoardDetail, LaborDetail, PricingDetail 등 상세 페이지 권한 적용
- ProcessDetail, StepDetail, ItemDetail, PermissionDetail 권한 연동
- RootProvider에 PermissionProvider 통합
- protected layout 권한 체크 추가
- Claude 프로젝트 설정 파일 추가
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 10:17:02 +09:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { usePermission } from '@/hooks/usePermission';
|
2026-02-04 12:46:19 +09:00
|
|
|
import type { PermissionAction, UsePermissionReturn } from '@/lib/permissions/types';
|
feat(WEB): 권한 관리 시스템 구현 및 상세 페이지 권한 통합
- PermissionContext, usePermission 훅, PermissionGuard 컴포넌트 신규 추가
- AccessDenied 접근 거부 페이지 추가
- permissions lib (체커, 매퍼, 타입) 구현
- BadDebtDetail, BoardDetail, LaborDetail, PricingDetail 등 상세 페이지 권한 적용
- ProcessDetail, StepDetail, ItemDetail, PermissionDetail 권한 연동
- RootProvider에 PermissionProvider 통합
- protected layout 권한 체크 추가
- Claude 프로젝트 설정 파일 추가
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 10:17:02 +09:00
|
|
|
|
|
|
|
|
interface PermissionGuardProps {
|
|
|
|
|
action: PermissionAction;
|
|
|
|
|
/** 다른 메뉴 권한 체크 시 URL 직접 지정 (생략하면 현재 URL 자동 매칭) */
|
|
|
|
|
url?: string;
|
|
|
|
|
/** 권한 없을 때 대체 UI (기본: 렌더링 안 함) */
|
|
|
|
|
fallback?: React.ReactNode;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 버튼/영역 레벨 권한 제어 컴포넌트
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* // 현재 페이지 기준 (URL 자동매칭)
|
|
|
|
|
* <PermissionGuard action="delete">
|
|
|
|
|
* <Button variant="destructive">삭제</Button>
|
|
|
|
|
* </PermissionGuard>
|
|
|
|
|
*
|
|
|
|
|
* // 다른 메뉴 권한 체크
|
|
|
|
|
* <PermissionGuard action="approve" url="/approval/inbox">
|
|
|
|
|
* <Button>승인</Button>
|
|
|
|
|
* </PermissionGuard>
|
|
|
|
|
*/
|
|
|
|
|
export function PermissionGuard({
|
|
|
|
|
action,
|
|
|
|
|
url,
|
|
|
|
|
fallback = null,
|
|
|
|
|
children,
|
|
|
|
|
}: PermissionGuardProps) {
|
|
|
|
|
const permission = usePermission(url);
|
|
|
|
|
|
2026-02-04 12:46:19 +09:00
|
|
|
const key = `can${action.charAt(0).toUpperCase()}${action.slice(1)}` as keyof UsePermissionReturn;
|
|
|
|
|
if (!permission[key]) {
|
feat(WEB): 권한 관리 시스템 구현 및 상세 페이지 권한 통합
- PermissionContext, usePermission 훅, PermissionGuard 컴포넌트 신규 추가
- AccessDenied 접근 거부 페이지 추가
- permissions lib (체커, 매퍼, 타입) 구현
- BadDebtDetail, BoardDetail, LaborDetail, PricingDetail 등 상세 페이지 권한 적용
- ProcessDetail, StepDetail, ItemDetail, PermissionDetail 권한 연동
- RootProvider에 PermissionProvider 통합
- protected layout 권한 체크 추가
- Claude 프로젝트 설정 파일 추가
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 10:17:02 +09:00
|
|
|
return <>{fallback}</>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <>{children}</>;
|
|
|
|
|
}
|