Kaynağa Gözat

fix(inbounds): correct per-inbound client counts and align stat colors

The client column under-counted clients attached to an inbound whose shared client_traffics row is keyed to a different inbound: rollupClients filtered settings.clients down to emails that had a stat row on that inbound. Count from settings.clients membership instead. Also surface all/active/disable/depleted/online with the Clients-page color scheme and widen the column.
MHSanaei 10 saat önce
ebeveyn
işleme
d2058f07dd

+ 16 - 15
frontend/src/pages/inbounds/list/useInboundColumns.tsx

@@ -1,6 +1,7 @@
 import { useMemo, type ReactElement } from 'react';
 import { useTranslation } from 'react-i18next';
 import { Popover, Switch, Tag, type TableColumnType } from 'antd';
+import { TeamOutlined } from '@ant-design/icons';
 
 import { SizeFormatter, IntlUtil, ColorUtils } from '@/utils';
 import { InfinityIcon } from '@/components/ui';
@@ -152,49 +153,49 @@ export function useInboundColumns({
         title: t('clients'),
         key: 'clients',
         align: 'left',
-        width: 50,
+        width: 80,
         render: (_, record) => {
           const cc = clientCount[record.id];
           if (!cc) return null;
           return (
             <>
-              <Tag color="green" className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>
-                {cc.clients}
+              <Tag className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>
+                <TeamOutlined /> {cc.clients}
               </Tag>
-              {cc.deactive.length > 0 && (
+              {cc.active.length > 0 && (
                 <Popover
-                  title={t('disabled')}
+                  title={t('subscription.active')}
                   content={(
                     <div className="client-email-list">
-                      {cc.deactive.map((e) => <div key={e}>{e}</div>)}
+                      {cc.active.map((e) => <div key={e}>{e}</div>)}
                     </div>
                   )}
                 >
-                  <Tag className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>{cc.deactive.length}</Tag>
+                  <Tag color="green" className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>{cc.active.length}</Tag>
                 </Popover>
               )}
-              {cc.depleted.length > 0 && (
+              {cc.deactive.length > 0 && (
                 <Popover
-                  title={t('depleted')}
+                  title={t('disabled')}
                   content={(
                     <div className="client-email-list">
-                      {cc.depleted.map((e) => <div key={e}>{e}</div>)}
+                      {cc.deactive.map((e) => <div key={e}>{e}</div>)}
                     </div>
                   )}
                 >
-                  <Tag color="red" className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>{cc.depleted.length}</Tag>
+                  <Tag className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>{cc.deactive.length}</Tag>
                 </Popover>
               )}
-              {cc.expiring.length > 0 && (
+              {cc.depleted.length > 0 && (
                 <Popover
-                  title={t('depletingSoon')}
+                  title={t('depleted')}
                   content={(
                     <div className="client-email-list">
-                      {cc.expiring.map((e) => <div key={e}>{e}</div>)}
+                      {cc.depleted.map((e) => <div key={e}>{e}</div>)}
                     </div>
                   )}
                 >
-                  <Tag color="orange" className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>{cc.expiring.length}</Tag>
+                  <Tag color="red" className="client-count-tag" style={{ margin: 0, padding: '0 2px' }}>{cc.depleted.length}</Tag>
                 </Popover>
               )}
               {cc.online.length > 0 && (

+ 1 - 8
frontend/src/pages/inbounds/useInbounds.ts

@@ -142,14 +142,7 @@ export function useInbounds() {
       const clientStats = Array.isArray((dbInbound as { clientStats?: unknown }).clientStats)
         ? (dbInbound as unknown as { clientStats: { email: string; total: number; up: number; down: number; expiryTime: number }[] }).clientStats
         : [];
-      const allClients = inbound?.clients || [];
-      const statsEmails = new Set<string>();
-      for (const s of clientStats) {
-        if (s && s.email) statsEmails.add(s.email);
-      }
-      const clients = clientStats.length > 0
-        ? allClients.filter((c) => c && c.email && statsEmails.has(c.email))
-        : allClients;
+      const clients = inbound?.clients || [];
       const active: string[] = [];
       const deactive: string[] = [];
       const depleted: string[] = [];