fix: 직원 프로필 조회 호출 메서드 및 백엔드 응답 바인딩 오류 보정
This commit is contained in:
@@ -77,24 +77,35 @@ export default function DynamicEmployeeProfilePage() {
|
||||
setError(null);
|
||||
|
||||
const [empRes, historyRes, contactRes] = await Promise.allSettled([
|
||||
employeeService.getById(empId),
|
||||
employeeService.getOne(empId),
|
||||
employeeService.getDispatchHistories(empId),
|
||||
apiClient.get<any>(`/employees/${empId}/emergency-contacts`),
|
||||
]);
|
||||
|
||||
if (empRes.status === 'fulfilled' && empRes.value?.success) {
|
||||
setEmployee(empRes.value.data);
|
||||
if (empRes.status === 'fulfilled' && empRes.value) {
|
||||
const val = empRes.value as any;
|
||||
const empData = val.data ?? val;
|
||||
if (empData && empData.empId) {
|
||||
setEmployee(empData);
|
||||
} else {
|
||||
setError('직원 정보를 찾을 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
setError('직원 정보를 찾을 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (historyRes.status === 'fulfilled' && historyRes.value?.success) {
|
||||
setDispatchHistories(Array.isArray(historyRes.value.data) ? historyRes.value.data : []);
|
||||
if (historyRes.status === 'fulfilled' && historyRes.value) {
|
||||
const val = historyRes.value as any;
|
||||
const list = val.data ?? val;
|
||||
setDispatchHistories(Array.isArray(list) ? list : []);
|
||||
}
|
||||
|
||||
if (contactRes.status === 'fulfilled' && contactRes.value?.data) {
|
||||
setEmergencyContacts(contactRes.value.data);
|
||||
if (contactRes.status === 'fulfilled' && contactRes.value) {
|
||||
const val = contactRes.value as any;
|
||||
const list = val.data ?? val;
|
||||
setEmergencyContacts(Array.isArray(list) ? list : []);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@@ -478,7 +489,7 @@ export default function DynamicEmployeeProfilePage() {
|
||||
>
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold text-text-main">
|
||||
{dh.projectName || '프로젝트'}
|
||||
{(dh as any).projectName || (dh as any).project?.projectName || '프로젝트'}
|
||||
</h4>
|
||||
{dh.roleTitle && (
|
||||
<p className="text-xs text-primary font-medium mt-0.5">{dh.roleTitle}</p>
|
||||
|
||||
@@ -18,6 +18,10 @@ const employeeService = {
|
||||
return apiClient.get<ApiResponse<Employee>>(`/employees/${empId}`);
|
||||
},
|
||||
|
||||
getById(empId: number) {
|
||||
return apiClient.get<ApiResponse<Employee>>(`/employees/${empId}`);
|
||||
},
|
||||
|
||||
getMe() {
|
||||
return apiClient.get<ApiResponse<Employee>>('/employees/me');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user