feat: 단가관리 페이지 마이그레이션 및 HR 관리 기능 추가
## 단가관리 (Pricing Management) - 단가 목록 페이지 (IntegratedListTemplateV2 공통 템플릿 적용) - 단가 등록/수정 폼 (원가/마진 자동 계산) - 이력 조회, 수정 이력, 최종 확정 다이얼로그 - 판매관리 > 단가관리 네비게이션 메뉴 추가 ## HR 관리 (Human Resources) - 사원관리 (목록, 등록, 수정, 상세, CSV 업로드) - 부서관리 (트리 구조) - 근태관리 (기본 구조) ## 품목관리 개선 - Radix UI Select controlled mode 버그 수정 (key prop 적용) - DynamicItemForm 파일 업로드 지원 - 수정 페이지 데이터 로딩 개선 ## 문서화 - 단가관리 마이그레이션 체크리스트 - HR 관리 구현 체크리스트 - Radix UI Select 버그 수정 가이드 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -74,22 +74,32 @@ async function refreshAccessToken(refreshToken: string): Promise<{
|
||||
|
||||
/**
|
||||
* 백엔드 API 요청 실행 함수
|
||||
*
|
||||
* @param isFormData - true인 경우 Content-Type 헤더를 생략 (브라우저가 boundary 자동 설정)
|
||||
*/
|
||||
async function executeBackendRequest(
|
||||
url: URL,
|
||||
method: string,
|
||||
token: string | undefined,
|
||||
body: string | undefined,
|
||||
contentType: string
|
||||
body: string | FormData | undefined,
|
||||
contentType: string,
|
||||
isFormData: boolean = false
|
||||
): Promise<Response> {
|
||||
// FormData인 경우 Content-Type을 생략해야 브라우저가 boundary를 자동 설정
|
||||
const headers: Record<string, string> = {
|
||||
'Accept': 'application/json',
|
||||
'X-API-KEY': process.env.NEXT_PUBLIC_API_KEY || '',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
};
|
||||
|
||||
// FormData가 아닌 경우에만 Content-Type 설정
|
||||
if (!isFormData) {
|
||||
headers['Content-Type'] = contentType;
|
||||
}
|
||||
|
||||
return fetch(url.toString(), {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': contentType,
|
||||
'Accept': 'application/json',
|
||||
'X-API-KEY': process.env.NEXT_PUBLIC_API_KEY || '',
|
||||
'Authorization': token ? `Bearer ${token}` : '',
|
||||
},
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
}
|
||||
@@ -162,8 +172,9 @@ async function proxyRequest(
|
||||
});
|
||||
|
||||
// 3. 요청 바디 읽기 (POST, PUT, DELETE, PATCH)
|
||||
let body: string | undefined;
|
||||
let body: string | FormData | undefined;
|
||||
const contentType = request.headers.get('content-type') || 'application/json';
|
||||
let isFormData = false;
|
||||
|
||||
if (['POST', 'PUT', 'DELETE', 'PATCH'].includes(method)) {
|
||||
if (contentType.includes('application/json')) {
|
||||
@@ -171,16 +182,38 @@ async function proxyRequest(
|
||||
console.log('🔵 [PROXY] Request:', method, url.toString());
|
||||
console.log('🔵 [PROXY] Request Body:', body); // 디버깅용
|
||||
} else if (contentType.includes('multipart/form-data')) {
|
||||
// multipart는 formData로 처리해야 하지만, 현재는 지원하지 않음
|
||||
console.warn('🟡 [PROXY] multipart/form-data is not fully supported');
|
||||
body = await request.text();
|
||||
// multipart/form-data 처리: FormData를 그대로 전달
|
||||
console.log('📎 [PROXY] Processing multipart/form-data request');
|
||||
isFormData = true;
|
||||
|
||||
// 원본 요청의 FormData 읽기
|
||||
const originalFormData = await request.formData();
|
||||
|
||||
// 새 FormData 생성 (백엔드 전송용)
|
||||
const newFormData = new FormData();
|
||||
|
||||
// 모든 필드 복사
|
||||
for (const [key, value] of originalFormData.entries()) {
|
||||
if (value instanceof File) {
|
||||
// File 객체는 그대로 추가
|
||||
newFormData.append(key, value, value.name);
|
||||
console.log(`📎 [PROXY] File field: ${key} = ${value.name} (${value.size} bytes)`);
|
||||
} else {
|
||||
// 일반 필드
|
||||
newFormData.append(key, value);
|
||||
console.log(`📎 [PROXY] Form field: ${key} = ${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
body = newFormData;
|
||||
console.log('🔵 [PROXY] Request:', method, url.toString());
|
||||
}
|
||||
} else {
|
||||
console.log('🔵 [PROXY] Request:', method, url.toString());
|
||||
}
|
||||
|
||||
// 4. 백엔드로 프록시 요청
|
||||
let backendResponse = await executeBackendRequest(url, method, token, body, contentType);
|
||||
let backendResponse = await executeBackendRequest(url, method, token, body, contentType, isFormData);
|
||||
let newTokens: { accessToken?: string; refreshToken?: string; expiresIn?: number } | null = null;
|
||||
|
||||
// 5. 🔄 401 응답 시 토큰 갱신 후 재시도
|
||||
@@ -195,7 +228,7 @@ async function proxyRequest(
|
||||
// 새 토큰으로 원래 요청 재시도
|
||||
token = refreshResult.accessToken;
|
||||
newTokens = refreshResult;
|
||||
backendResponse = await executeBackendRequest(url, method, token, body, contentType);
|
||||
backendResponse = await executeBackendRequest(url, method, token, body, contentType, isFormData);
|
||||
|
||||
console.log('🔵 [PROXY] Retry response status:', backendResponse.status);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user