mirror of
https://git.boos.lat/aibo/BossChat.git
synced 2026-10-30 15:16:11 +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(
|
function buildTagOptions(
|
||||||
nodes: TagTree[],
|
nodes: TagTree[] | null,
|
||||||
parentPath = ""
|
parentPath = ""
|
||||||
): ComboboxOption[] {
|
): ComboboxOption[] {
|
||||||
const result: ComboboxOption[] = []
|
const result: ComboboxOption[] = []
|
||||||
|
if (!nodes) return result
|
||||||
nodes.forEach((item) => {
|
nodes.forEach((item) => {
|
||||||
const currentPath = parentPath ? `${parentPath}/${item.name}` : item.name
|
const currentPath = parentPath ? `${parentPath}/${item.name}` : item.name
|
||||||
result.push({
|
result.push({
|
||||||
@@ -207,18 +208,18 @@ export default function DashboardConversationsPage() {
|
|||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
setTagOptions([
|
setTagOptions([
|
||||||
{ value: "0", label: "全部标签" },
|
{ value: "0", label: "全部标签" },
|
||||||
...buildTagOptions(tagData),
|
...buildTagOptions(tagData || []),
|
||||||
])
|
])
|
||||||
setAssigneeOptions([
|
setAssigneeOptions([
|
||||||
{ value: "0", label: "全部指派人" },
|
{ value: "0", label: "全部指派人" },
|
||||||
...assigneeData.map((item: AdminAgentProfile) => ({
|
...(Array.isArray(assigneeData) ? assigneeData : []).map((item: AdminAgentProfile) => ({
|
||||||
value: String(item.userId),
|
value: String(item.userId),
|
||||||
label: item.displayName || item.nickname || item.username || `#${item.userId}`,
|
label: item.displayName || item.nickname || item.username || `#${item.userId}`,
|
||||||
})),
|
})),
|
||||||
])
|
])
|
||||||
setAgentTeamOptions([
|
setAgentTeamOptions([
|
||||||
{ value: "0", label: "全部客服组" },
|
{ value: "0", label: "全部客服组" },
|
||||||
...teamData.map((item: AdminAgentTeam) => ({
|
...(Array.isArray(teamData) ? teamData : []).map((item: AdminAgentTeam) => ({
|
||||||
value: String(item.id),
|
value: String(item.id),
|
||||||
label: item.name,
|
label: item.name,
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in New Issue
Block a user