Files
replypier/frontend/src/utils/channelAccounts.ts
T
WangShen007 83a16ed07d feat(modules): 帮助中心、工单、工作流与多渠道接入
补齐 FAQ、帮助中心、工单、可视化工作流及 Telegram/WhatsApp/Slack 等渠道模块。
2026-10-17 22:05:00 +08:00

32 lines
1.4 KiB
TypeScript

/*
Copyright 2024-2026 ChatterMate
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import type { ChannelAccount } from '@/services/channels'
/** The integration-card warning for accounts whose platform stopped accepting
* their credentials, or undefined when every account is healthy. */
export const reconnectWarning = (accounts: ChannelAccount[]): string | undefined => {
const expired = accounts.filter(a => a.needs_reconnect)
if (!expired.length) return undefined
const names = expired.map(a => a.display_name || a.external_account_id).join(', ')
return `以下账号的访问权限已过期:${names},请重新连接以恢复回复。`
}
/** The account a card's Manage opens: one that needs reconnecting first, so
* the card's warning leads to its fix, else the first connected. */
export const accountToManage = (accounts: ChannelAccount[]): ChannelAccount | null =>
accounts.find(a => a.needs_reconnect) ?? accounts[0] ?? null