@jsb188/mday-web 1.1.11 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,9 @@
1
- import i18n from '@jsb188/app/i18n/index.ts';
2
1
  import { getCronDescription } from '@jsb188/app/utils/cron.ts';
3
2
  import { getFullDate } from '@jsb188/app/utils/datetime.ts';
4
3
  import type { WorkflowGQL } from '@jsb188/mday/types/workflow.d.ts';
5
- import {
6
- getWorkflowShortLabel,
7
- isRecurringReminder,
8
- isWorkflowActive,
9
- } from '@jsb188/mday/utils/workflow.ts';
4
+ import { isRecurringReminder } from '@jsb188/mday/utils/workflow.ts';
10
5
  import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
6
+ import { getLogActivityGroupIconName } from './log-web.ts';
11
7
 
12
8
  /*
13
9
  * Return the icon name used to represent one workflow trigger.
@@ -15,82 +11,35 @@ import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
15
11
  export function getWorkflowIconName(workflow: WorkflowGQL) {
16
12
  const firstLogType = workflow.logTypes?.[0];
17
13
 
18
- return firstLogType
19
- ? COMMON_ICON_NAMES[firstLogType] || COMMON_ICON_NAMES.general_workflow
20
- : COMMON_ICON_NAMES.general_workflow;
21
- }
22
-
23
- /*
24
- * Return the formatted next run date for one workflow, or a table-friendly empty value.
25
- */
26
- export function getWorkflowNextRunText(
27
- workflow: WorkflowGQL,
28
- timeZone: string | null,
29
- ) {
30
- return workflow.nextAt
31
- ? getFullDate(workflow.nextAt, 'NUMERIC_TIME', timeZone)
32
- : '-';
14
+ return firstLogType ? getLogActivityGroupIconName(firstLogType) : COMMON_ICON_NAMES.general_workflow;
33
15
  }
34
16
 
35
17
  /*
36
18
  * Return the schedule description for one reminder (cron text or one-time date).
37
19
  */
38
- export function getReminderScheduleText(
39
- reminder: Pick<WorkflowGQL, 'triggerType' | 'schedule' | 'nextAt'>,
40
- timeZone: string | null,
41
- ) {
20
+ export function getReminderScheduleText(reminder: Pick<WorkflowGQL, 'triggerType' | 'schedule' | 'nextAt'>, timeZone: string | null) {
42
21
  if (isRecurringReminder(reminder) && reminder.schedule) {
43
22
  return getCronDescription(reminder.schedule, true);
44
23
  }
45
24
 
46
- return reminder.nextAt
47
- ? getFullDate(reminder.nextAt, 'NUMERIC_TIME', timeZone)
48
- : '-';
25
+ return reminder.nextAt ? getFullDate(reminder.nextAt, 'NUMERIC_TIME', timeZone) : '-';
49
26
  }
50
27
 
51
28
  /*
52
29
  * Return the short recipients summary for one reminder (names/addresses).
53
30
  */
54
- export function getReminderRecipientsSummaryText(
55
- reminder: Pick<WorkflowGQL, 'recipients'>,
56
- ) {
57
- const labels = (reminder.recipients || [])
58
- .map(
59
- (recipient) => recipient.name || recipient.phone || recipient.email || '',
60
- )
61
- .filter(Boolean);
31
+ export function getReminderRecipientsSummaryText(reminder: Pick<WorkflowGQL, 'recipients'>) {
32
+ if (!reminder.recipients?.length) return null;
33
+
34
+ const labels = reminder.recipients.map((recipient) => recipient.name || recipient.phone || recipient.email || '').filter(Boolean);
62
35
 
63
36
  if (!labels.length) {
64
- return '-';
37
+ return null;
65
38
  }
66
39
 
67
40
  if (labels.length <= 2) {
68
41
  return labels.join(', ');
69
42
  }
70
43
 
71
- return `${labels.slice(0, 2).join(', ')} +${labels.length - 2}`;
72
- }
73
-
74
- /*
75
- * Return the modal header description for one workflow's current scheduling state.
76
- */
77
- export function getWorkflowHeaderDescription(
78
- workflow: WorkflowGQL,
79
- timeZone: string | null,
80
- ) {
81
- if (!isWorkflowActive(workflow)) {
82
- return i18n.t('workflow.not_active_msg');
83
- }
84
-
85
- if (workflow.nextAt) {
86
- return `${i18n.t('form.next_run')}: ${getWorkflowNextRunText(workflow, timeZone)}`;
87
- }
88
-
89
- const logTypeShortLabel = workflow.logTypes?.length
90
- ? getWorkflowShortLabel(workflow)
91
- : null;
92
-
93
- return i18n.t('workflow.active_msg', {
94
- logType: logTypeShortLabel?.toLowerCase(),
95
- });
44
+ return `${labels[0]}, ${labels[1]} +${labels.length - 2}`;
96
45
  }