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