mirror of
https://git.boos.lat/aibo/BossChat.git
synced 2026-10-30 07:06:08 +00:00
fix: null safety in conversation monitor page
Prevent "Cannot read properties of null (reading forEach)" when fetchTagsAll / fetchAgentProfilesAll / fetchAgentTeamsAll return null from the API. Add null guard in buildTagOptions and array checks for assignee/team data before calling .map.
This commit is contained in:
@@ -107,10 +107,11 @@ function getStatusLabel(value: string) {
|
||||
}
|
||||
|
||||
function buildTagOptions(
|
||||
nodes: TagTree[],
|
||||
nodes: TagTree[] | null,
|
||||
parentPath = ""
|
||||
): ComboboxOption[] {
|
||||
const result: ComboboxOption[] = []
|
||||
if (!nodes) return result
|
||||
nodes.forEach((item) => {
|
||||
const currentPath = parentPath ? `${parentPath}/${item.name}` : item.name
|
||||
result.push({
|
||||
@@ -207,18 +208,18 @@ export default function DashboardConversationsPage() {
|
||||
if (!cancelled) {
|
||||
setTagOptions([
|
||||
{ value: "0", label: "全部标签" },
|
||||
...buildTagOptions(tagData),
|
||||
...buildTagOptions(tagData || []),
|
||||
])
|
||||
setAssigneeOptions([
|
||||
{ value: "0", label: "全部指派人" },
|
||||
...assigneeData.map((item: AdminAgentProfile) => ({
|
||||
...(Array.isArray(assigneeData) ? assigneeData : []).map((item: AdminAgentProfile) => ({
|
||||
value: String(item.userId),
|
||||
label: item.displayName || item.nickname || item.username || `#${item.userId}`,
|
||||
})),
|
||||
])
|
||||
setAgentTeamOptions([
|
||||
{ value: "0", label: "全部客服组" },
|
||||
...teamData.map((item: AdminAgentTeam) => ({
|
||||
...(Array.isArray(teamData) ? teamData : []).map((item: AdminAgentTeam) => ({
|
||||
value: String(item.id),
|
||||
label: item.name,
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user