feat: Enhance user mapping in BOM and inventory pages

- Updated API calls in the InventoryStatusPage and BomManagementPage to fetch user data with a limit of 9999 users, improving performance and ensuring all users are loaded.
- Implemented user mapping to display user names instead of IDs, enhancing clarity in user-related data across multiple company implementations.
- These changes aim to improve the overall user experience by providing clearer information and better data management in the logistics and BOM sections.
This commit is contained in:
kjs
2026-04-12 21:31:36 +09:00
parent e8eeef1e53
commit 96b9ac78db
14 changed files with 105 additions and 21 deletions
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -433,6 +435,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1802,7 +1814,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -434,6 +436,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1804,7 +1816,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -433,6 +435,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1802,7 +1814,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -433,6 +435,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1802,7 +1814,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -434,6 +436,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1764,7 +1776,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -433,6 +435,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1801,7 +1813,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}
@@ -171,11 +171,11 @@ export default function InventoryStatusPage() {
};
load();
// 사용자 목록 로드
apiClient.get("/admin/users").then((res) => {
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.user_id || u.id;
const id = u.userId || u.user_id || u.id;
const name = u.user_name || u.name || id;
if (id) map[id] = name;
}
@@ -309,6 +309,8 @@ export default function BomManagementPage() {
// 카테고리 옵션
const [categoryOptions, setCategoryOptions] = useState<Record<string, { code: string; label: string }[]>>({});
// 사용자 맵 (userId → userName)
const [userMap, setUserMap] = useState<Record<string, string>>({});
// 트리 편집 state
const [editingTree, setEditingTree] = useState<TreeNode[]>([]);
@@ -433,6 +435,16 @@ export default function BomManagementPage() {
} catch {}
};
loadCategories();
// 사용자 목록 로드
apiClient.get("/admin/users", { params: { size: 9999 } }).then((res) => {
const users = res.data?.data || res.data || [];
const map: Record<string, string> = {};
for (const u of users) {
const id = u.userId || u.user_id || u.id;
if (id) map[id] = u.userName || u.user_name || u.name || id;
}
setUserMap(map);
}).catch(() => {});
}, []);
// ─── BOM 상세 로드 ────────────────────────────
@@ -1802,7 +1814,7 @@ export default function BomManagementPage() {
{/* 비고 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2">{isVirtualRoot ? "-" : (node.remark || "-")}</td>
{/* 작성자 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (node.writer || "-")}</td>
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">{isVirtualRoot ? "-" : (userMap[node.writer] || node.writer || "-")}</td>
{/* 수정일시 */}
<td className="overflow-hidden text-ellipsis whitespace-nowrap px-3 py-2 text-muted-foreground">
{isVirtualRoot ? "-" : (node.updated_date ? new Date(node.updated_date).toLocaleString("ko-KR", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }) : "-")}