fix some bugs from chart

This commit is contained in:
2026-08-01 15:54:13 +03:30
parent 31836f3f8e
commit 1aa8f6b867
6 changed files with 245 additions and 19 deletions
+12
View File
@@ -1,3 +1,5 @@
import { toJalali } from '@core/utils/useDataTime'
/** هم‌تراز با CustomerPresenceService::ONLINE_THRESHOLD_SECONDS روی سرور */
export const CUSTOMER_ONLINE_THRESHOLD_MS = 2 * 60 * 1000
@@ -16,3 +18,13 @@ export function getCustomerPresenceKind(
export function isCustomerOnline(lastSeenAt: string | Date | null | undefined): boolean {
return getCustomerPresenceKind(lastSeenAt) === 'online'
}
/** متن وضعیت برای چت (به‌جای «نامشخص») */
export function formatCustomerPresenceLabel(
lastSeenAt: string | Date | null | undefined
): string {
const kind = getCustomerPresenceKind(lastSeenAt)
if (kind === 'online') return 'آنلاین'
if (kind === 'never') return 'آفلاین'
return lastSeenAt ? `آخرین بازدید ${toJalali(lastSeenAt as string)}` : 'آفلاین'
}