fix(대무자): Select 후보 목록 - getUserList 응답 shape 호환
SubstituteSection 의 loadCandidates 가 res.data.list 를 가정했지만
getUserList(/api/admin/users) 응답은 { data: [...] } 형태 (data 가 list 자체).
결과로 모든 select 가 '지정 가능한 사용자가 없습니다' 로 표시됐음.
Array.isArray(res.data) 와 res.data.list 둘 다 fallback 으로 처리.
This commit is contained in:
@@ -78,9 +78,17 @@ export function SubstituteSection({ originalUserId, originalUserName }: Substitu
|
||||
// 대무자 후보 사용자 목록 로드 (다이얼로그 열릴 때 한번)
|
||||
const loadCandidates = useCallback(async () => {
|
||||
setCandidatesLoading(true);
|
||||
const res = await getUserList({ status: "active", limit: 1000 });
|
||||
if (res?.success && Array.isArray(res.data?.list)) {
|
||||
const filtered = (res.data.list as Record<string, any>[]).filter(
|
||||
const res: any = await getUserList({ status: "active", limit: 1000 });
|
||||
// user.ts 의 getUserList 는 axios response 의 data 를 반환:
|
||||
// { success, data: [...], total, ... } (data 가 list 자체)
|
||||
// 또는 cross-tenant mode 등에서 { data: { list: [...] } } 일 수도 있어 둘 다 지원.
|
||||
const rawList: any[] = Array.isArray(res?.data)
|
||||
? res.data
|
||||
: Array.isArray(res?.data?.list)
|
||||
? res.data.list
|
||||
: [];
|
||||
if (rawList.length > 0) {
|
||||
const filtered = (rawList as Record<string, any>[]).filter(
|
||||
(u) =>
|
||||
u.user_id !== originalUserId &&
|
||||
u.user_type !== "SUPER_ADMIN" &&
|
||||
|
||||
Reference in New Issue
Block a user