chore: complete clean Agent Desk source snapshot

This commit is contained in:
2026-10-16 12:03:16 +00:00
parent 756ae33d05
commit e57610a27c
123 changed files with 37513 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import { translateCurrentMessage, translateMessage } from "@/i18n/messages"
import type { AppLocale } from "@/i18n/config"
/**
* Localized display names for IMConversationStatus.
*
* The generated enum labels are Chinese-only, so they cannot be shown to an
* English or Russian visitor. Keeping the number-to-key mapping here - rather
* than switching on locale inside a component - means the widget, the demo and
* any later surface all read the same vocabulary.
*/
const CONVERSATION_STATUS_MESSAGE_KEYS: Record<number, string> = {
1: "supportChat.statusAiServing",
2: "supportChat.statusPending",
3: "supportChat.statusActive",
4: "supportChat.statusClosed",
}
/**
* Falls back to the closed label for an unknown status. A request is either
* finished or not, and mislabelling it as finished is the safer error: it
* invites the visitor to reopen it rather than hiding that it is still live.
*/
const UNKNOWN_STATUS_MESSAGE_KEY = "supportChat.statusClosed"
export function getConversationStatusMessageKey(status: number): string {
return CONVERSATION_STATUS_MESSAGE_KEYS[status] ?? UNKNOWN_STATUS_MESSAGE_KEY
}
export function getConversationStatusLabel(
status: number,
locale?: AppLocale
): string {
const key = getConversationStatusMessageKey(status)
return locale ? translateMessage(locale, key) : translateCurrentMessage(key)
}
/**
* The generic title for a request the visitor did not name. Subject wins when
* present; this is what a list row shows instead.
*/
export function getConversationFallbackTitle(locale?: AppLocale): string {
return locale
? translateMessage(locale, "supportChat.requestFallbackTitle")
: translateCurrentMessage("supportChat.requestFallbackTitle")
}