feat: add AI serving status to conversation management and update related components
This commit is contained in:
@@ -49,13 +49,13 @@ type ConversationDetailDialogProps = {
|
||||
function getStatusMeta(status: number) {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return { label: "待接入", variant: "outline" as const };
|
||||
return { label: "AI接待中", variant: "secondary" as const };
|
||||
case 2:
|
||||
return { label: "处理中", variant: "secondary" as const };
|
||||
return { label: "待接入", variant: "outline" as const };
|
||||
case 3:
|
||||
return { label: "已关闭", variant: "outline" as const };
|
||||
return { label: "处理中", variant: "secondary" as const };
|
||||
case 4:
|
||||
return { label: "已归档", variant: "outline" as const };
|
||||
return { label: "已关闭", variant: "outline" as const };
|
||||
default:
|
||||
return { label: "未知", variant: "outline" as const };
|
||||
}
|
||||
@@ -151,8 +151,8 @@ export function ConversationDetailDialog({
|
||||
onOpenClose,
|
||||
}: ConversationDetailDialogProps) {
|
||||
const currentConversation = detail ?? item;
|
||||
const isClosedConversation = currentConversation?.status === 3;
|
||||
const isPendingConversation = currentConversation?.status === 1;
|
||||
const isClosedConversation = currentConversation?.status === 4;
|
||||
const isPendingConversation = currentConversation?.status === 2;
|
||||
const statusMeta = currentConversation
|
||||
? getStatusMeta(currentConversation.status)
|
||||
: null;
|
||||
@@ -274,7 +274,7 @@ export function ConversationDetailDialog({
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={onOpenAssign}
|
||||
disabled={saving || !currentConversation || isClosedConversation}
|
||||
disabled={saving || !currentConversation || currentConversation.status !== 2}
|
||||
>
|
||||
<MessageCircleMoreIcon />
|
||||
{saving ? "处理中..." : "分配会话"}
|
||||
@@ -301,7 +301,7 @@ export function ConversationDetailDialog({
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={onOpenTransfer}
|
||||
disabled={saving || !currentConversation || isClosedConversation}
|
||||
disabled={saving || !currentConversation || currentConversation.status !== 3}
|
||||
>
|
||||
<MessageCircleMoreIcon />
|
||||
{saving ? "处理中..." : "转接会话"}
|
||||
|
||||
@@ -68,22 +68,22 @@ const RECONNECT_MAX_DELAY = 30000
|
||||
|
||||
const statusOptions = [
|
||||
{ value: "all", label: "全部状态" },
|
||||
{ value: "1", label: "待接入" },
|
||||
{ value: "2", label: "处理中" },
|
||||
{ value: "3", label: "已关闭" },
|
||||
{ value: "4", label: "已归档" },
|
||||
{ value: "1", label: "AI接待中" },
|
||||
{ value: "2", label: "待接入" },
|
||||
{ value: "3", label: "处理中" },
|
||||
{ value: "4", label: "已关闭" },
|
||||
] as const
|
||||
|
||||
function getStatusMeta(status: number) {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return { label: "待接入", variant: "outline" as const }
|
||||
return { label: "AI接待中", variant: "secondary" as const }
|
||||
case 2:
|
||||
return { label: "处理中", variant: "secondary" as const }
|
||||
return { label: "待接入", variant: "outline" as const }
|
||||
case 3:
|
||||
return { label: "已关闭", variant: "outline" as const }
|
||||
return { label: "处理中", variant: "secondary" as const }
|
||||
case 4:
|
||||
return { label: "已归档", variant: "outline" as const }
|
||||
return { label: "已关闭", variant: "outline" as const }
|
||||
default:
|
||||
return { label: "未知", variant: "outline" as const }
|
||||
}
|
||||
@@ -761,14 +761,14 @@ export default function DashboardConversationsPage() {
|
||||
<DropdownMenuContent align="end" className="w-44 min-w-44">
|
||||
<DropdownMenuItem
|
||||
onClick={() => openAssign(item)}
|
||||
disabled={actionLoadingId === item.id || item.status !== 1}
|
||||
disabled={actionLoadingId === item.id || item.status !== 2}
|
||||
>
|
||||
<MessageCircleMoreIcon />
|
||||
{actionLoadingId === item.id ? "处理中..." : "分配会话"}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => void handleDispatch(item)}
|
||||
disabled={actionLoadingId === item.id || item.status !== 1}
|
||||
disabled={actionLoadingId === item.id || item.status !== 2}
|
||||
>
|
||||
<RefreshCwIcon />
|
||||
{actionLoadingId === item.id ? "处理中..." : "重试分配"}
|
||||
@@ -782,12 +782,12 @@ export default function DashboardConversationsPage() {
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => openTransfer(item)}
|
||||
disabled={actionLoadingId === item.id || item.status !== 2}
|
||||
disabled={actionLoadingId === item.id || item.status !== 3}
|
||||
>
|
||||
<MessageCircleMoreIcon />
|
||||
{actionLoadingId === item.id ? "处理中..." : "转接会话"}
|
||||
</DropdownMenuItem>
|
||||
{item.status !== 3 ? (
|
||||
{item.status !== 4 ? (
|
||||
<DropdownMenuItem
|
||||
onClick={() => openClose(item)}
|
||||
disabled={actionLoadingId === item.id}
|
||||
|
||||
@@ -86,8 +86,8 @@ export function ChatPanel() {
|
||||
const [claimDialogOpen, setClaimDialogOpen] = useState(false);
|
||||
const [transferDialogOpen, setTransferDialogOpen] = useState(false);
|
||||
const isLgUp = useIsLgUp();
|
||||
const isClosedConversation = conversation?.status === 3;
|
||||
const isPendingConversation = conversation?.status === 1;
|
||||
const isClosedConversation = conversation?.status === 4;
|
||||
const isPendingConversation = conversation?.status === 2;
|
||||
const showMessageEditor = !isClosedConversation && !isPendingConversation;
|
||||
const currentUserId = readSession()?.user?.id ?? 0;
|
||||
|
||||
@@ -397,6 +397,10 @@ export function ChatPanel() {
|
||||
<div className="bg-amber-500/10 px-4 py-3 text-sm text-amber-950 dark:bg-amber-500/15 dark:text-amber-100">
|
||||
当前会话已关闭
|
||||
</div>
|
||||
) : conversation?.status === 1 ? (
|
||||
<div className="bg-violet-500/10 px-4 py-3 text-sm text-violet-950 dark:bg-violet-500/15 dark:text-violet-100">
|
||||
当前会话由 AI 接待中,转人工后才能由客服发送消息
|
||||
</div>
|
||||
) : isPendingConversation ? (
|
||||
<div className="bg-blue-500/10 px-4 py-3 dark:bg-blue-500/15">
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -14,6 +14,8 @@ import { getEnumLabel } from "@/lib/enums"
|
||||
|
||||
function getStatusVariant(status: number) {
|
||||
switch (status) {
|
||||
case IMConversationStatus.AIServing:
|
||||
return "bg-violet-500/15 text-violet-700 dark:bg-violet-500/20 dark:text-violet-300"
|
||||
case IMConversationStatus.Pending:
|
||||
return "bg-blue-500/15 text-blue-700 dark:bg-blue-500/20 dark:text-blue-300"
|
||||
case IMConversationStatus.Active:
|
||||
|
||||
@@ -244,14 +244,14 @@ export default function ConversationsPage() {
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => setTransferOpen(true)}
|
||||
disabled={!conversation || conversation.status !== 2}
|
||||
disabled={!conversation || conversation.status !== 3}
|
||||
>
|
||||
<ArrowRightLeftIcon />
|
||||
转接会话
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => setCloseOpen(true)}
|
||||
disabled={!conversation || conversation.status === 3}
|
||||
disabled={!conversation || conversation.status === 4}
|
||||
>
|
||||
<CircleXIcon />
|
||||
关闭会话
|
||||
|
||||
Reference in New Issue
Block a user