@jsb188/mday-web 1.1.8 → 1.1.10
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.
- package/package.json +12 -6
- package/src/modules/DataTable-ContextMenu.tsx +169 -0
- package/src/modules/DataTable-InboundContact.tsx +523 -0
- package/src/modules/DataTable.tsx +5060 -0
- package/src/modules/Sheet-ContextMenu.tsx +161 -0
- package/src/modules/Sheet.tsx +28 -0
- package/src/modules/cell-save-beacon.ts +67 -0
- package/src/modules/dataTable-interaction-state.ts +276 -0
- package/src/modules/dataTable-shortcuts.ts +192 -0
- package/src/modules/dataTable-viewport.ts +89 -0
- package/src/modules/grid-cell-render.ts +72 -0
- package/src/modules/grid-context-menu.ts +112 -0
- package/src/modules/grid-keyboard.ts +267 -0
- package/src/modules/grid-render-store.ts +103 -0
- package/src/modules/grid-runtime.ts +178 -0
- package/src/modules/grid-selection.ts +336 -0
- package/src/modules/grid-viewport.ts +57 -0
- package/src/modules/use-dataTable-states.ts +529 -0
- package/src/modules/use-debounced-cell-save-batch.ts +160 -0
- package/src/types/css.d.ts +1 -0
- package/src/utils/log-web.ts +440 -0
- package/src/utils/org-web.ts +40 -0
- package/src/utils/route-helpers.ts +244 -137
- package/tests/DataTable.test.tsx +4466 -0
- package/tests/dataTable-interaction-state.test.ts +127 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import { formatCurrency } from '@jsb188/app/utils/number.ts';
|
|
2
|
+
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
3
|
+
|
|
4
|
+
const ARABLE_ICON_WORD_GROUPS: [string, string[]][] = [
|
|
5
|
+
['vegetable-lettuce-top', ['little gem', 'lil gem', 'marciano', 'red butter', 'green gem', 'red gem', 'gems\\b', 'spretnak', 'newham', 'bokchoy', 'bok choy']],
|
|
6
|
+
['vegetable-lettuce', ['lettuce', 'red oak', 'romaine', 'escarol', 'radicchio', 'braci ardenti', 'braci adenti', 'di lusia', 'di lusio', 'treviso', 'thaddeus', 'cruced\\b']],
|
|
7
|
+
['vegetable-lavender', ['lavendar', 'lavender', 'anise hyssop', 'alyssum']],
|
|
8
|
+
['vegetable-basil', ['basil']],
|
|
9
|
+
['vegetable-beet', ['chioggia', 'beet', 'yellow tooth']],
|
|
10
|
+
['vegetable-broccoli', ['cauliflow', 'broccoli', 'piracicab']],
|
|
11
|
+
['vegetable-pumpkin', ['pumpkin', 'pump\\b', 'cargo pump', 'bennings green', 'benning']],
|
|
12
|
+
['vegetable-spinach', ['mesclun', 'spinach', 'chard', 'mustard green', 'mix\\b']],
|
|
13
|
+
['vegetable-tomato', ['tomato']],
|
|
14
|
+
['fruit-grapes', ['grapes']],
|
|
15
|
+
['fruit-apricot', ['apricot', 'peach', 'plum']],
|
|
16
|
+
['raspberry', ['raspberr']],
|
|
17
|
+
['fruit-cloud-berry', ['blackberr', 'cloudberr', 'cloud berr']],
|
|
18
|
+
['fruit-billberry-blackberry-blueberry', ['blueberr', 'billberr', 'berry', '\\w*berr(?:y|ies)\\b']],
|
|
19
|
+
['vegetable-asparagus', ['asparagus']],
|
|
20
|
+
['vegetable-acornsquash', ['sunshine kabocha', 'acorn squash', 'acornsquash', 'yellow star patty', 'sweet pepper', 'bell pepper']],
|
|
21
|
+
['fruit-strawberry', ['strawberr']], // commented now for testing
|
|
22
|
+
['seasoning-chilli', ['pepper', 'chilli']],
|
|
23
|
+
['vegetable-delicata-squash', ['delicata', 'delicata squash']],
|
|
24
|
+
['vegetable-hubbard-squash', ['hubbard squash', 'hubbard', 'red kuri']],
|
|
25
|
+
['vegetable-cucumber', ['shinto', 'cucumber', 'pickle']],
|
|
26
|
+
['vegetable-butternutsquash', ['butternut squash', 'butternutsquash', 'butternut', 'squash', 'starry night']],
|
|
27
|
+
['vegetable-thyme', ['summar savor', 'summer savor', 'summery savor', 'summary savor', 'thyme', 'rosemary', 'savory']],
|
|
28
|
+
['vegetable-arugula', ['arugula', 'chicory', 'puntarelle', 'frisee', 'kale', 'dino', 'green curl']],
|
|
29
|
+
['vegetable-parsley', ['parsley', 'beoc raab', 'wasabina', 'chervil']],
|
|
30
|
+
['vegetable-carrot', ['carrot']],
|
|
31
|
+
['vegetable-artichoke', ['artichoke', 'romanesco', 'star\\b', 'stars\\b']],
|
|
32
|
+
['vegetable-cabbage', ['cabbag']],
|
|
33
|
+
['vegetable-kohlrabi', ['kohlrab']],
|
|
34
|
+
['vegetable-zucchini', ['zucchini', 'zuchini', 'midnight light']],
|
|
35
|
+
['vegetable-potato', ['potato']],
|
|
36
|
+
['vegetable-eggplant', ['eggplant']],
|
|
37
|
+
['vegetable-jalapeno', ['jalapeno', 'jalapeño']],
|
|
38
|
+
['vegetable-stinging-kettle', ['stinging kettle', 'nettle', 'cardoon', 'cynara cardunculus', 'cardunculus', 'cresta', 'shiso']],
|
|
39
|
+
['vegetable-okra', ['okra']],
|
|
40
|
+
['plant-1', ['sage\\b', 'sages\\b', 'marjoram', 'sorrel', 'mint']],
|
|
41
|
+
['vegetable-scallion', ['scallion', 'scalion', 'spring onion', 'springonion']],
|
|
42
|
+
['gardening-seed-bag', ['seed']],
|
|
43
|
+
['vegetable-onion', ['onion', 'shallot', 'matador']],
|
|
44
|
+
['vegetable-black-bean', ['oliv']],
|
|
45
|
+
['vegetable-stringbean-1', ['bean', 'stringbean']],
|
|
46
|
+
['vegetable-cilantro', ['cilantro', 'flor\\b']],
|
|
47
|
+
['vegetable-radish', ['raddish', 'radish']],
|
|
48
|
+
['vegetable-wasabi', ['wasabi']],
|
|
49
|
+
['flower', ['flower']],
|
|
50
|
+
['product-growth-tree-box', ['soil']],
|
|
51
|
+
['gardening-sprinkler', ['irrigation']],
|
|
52
|
+
['agriculture-machine-seeder', ['direct seed']],
|
|
53
|
+
['organic-bag-leaf', ['fertilization']],
|
|
54
|
+
['gardening-tools-1', ['crop protection']],
|
|
55
|
+
['farming-barn-sun', ['crop monitoring', 'field']],
|
|
56
|
+
['gardening-scissors', ['pruning']],
|
|
57
|
+
['barbed-wire-fence', ['trellising']],
|
|
58
|
+
['protein-gluten-wheat', ['preparing crops']],
|
|
59
|
+
['harvest-product', ['crops', 'grading produce', 'moving produce']],
|
|
60
|
+
['crop-info-biotech-1', ['estimating yield', 'other harvest']],
|
|
61
|
+
['warehouse-storage', ['post harvest']],
|
|
62
|
+
['temperature-control-warehouse-1', ['cold storage temperature']],
|
|
63
|
+
['receipt-dollar', ['sale']],
|
|
64
|
+
['organic-flask', ['water testing', 'chlorine level']],
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const ARABLE_ICON_PRIORITY_WORDS = [
|
|
68
|
+
'little gem',
|
|
69
|
+
'lil gem',
|
|
70
|
+
'romaine',
|
|
71
|
+
'cauliflow',
|
|
72
|
+
'broccoli',
|
|
73
|
+
'piracicab',
|
|
74
|
+
'mesclun',
|
|
75
|
+
'spinach',
|
|
76
|
+
'mustard green',
|
|
77
|
+
'arugula',
|
|
78
|
+
'kale',
|
|
79
|
+
'kohlrab',
|
|
80
|
+
'cabbag',
|
|
81
|
+
'parsley',
|
|
82
|
+
'beoc raab',
|
|
83
|
+
'wasabina',
|
|
84
|
+
'chervil',
|
|
85
|
+
'basil',
|
|
86
|
+
'artichoke',
|
|
87
|
+
'romanesco',
|
|
88
|
+
'zucchini',
|
|
89
|
+
'zuchini',
|
|
90
|
+
'potato',
|
|
91
|
+
'eggplant',
|
|
92
|
+
'jalapeno',
|
|
93
|
+
'jalapeño',
|
|
94
|
+
'carrot',
|
|
95
|
+
'midnight light',
|
|
96
|
+
'cilantro',
|
|
97
|
+
'bennings green',
|
|
98
|
+
'lettuce',
|
|
99
|
+
'escarol',
|
|
100
|
+
'raddish',
|
|
101
|
+
'radish',
|
|
102
|
+
'bean',
|
|
103
|
+
'stringbean',
|
|
104
|
+
'oliv',
|
|
105
|
+
'stinging kettle',
|
|
106
|
+
'radicchio',
|
|
107
|
+
'braci ardenti',
|
|
108
|
+
'braci adenti',
|
|
109
|
+
'chicory',
|
|
110
|
+
'puntarelle',
|
|
111
|
+
'chioggia',
|
|
112
|
+
'beet',
|
|
113
|
+
'thaddeus',
|
|
114
|
+
'sunshine kabocha',
|
|
115
|
+
'yellow star patty',
|
|
116
|
+
'butternut squash',
|
|
117
|
+
'butternutsquash',
|
|
118
|
+
'asparagus',
|
|
119
|
+
'acorn squash',
|
|
120
|
+
'acornsquash',
|
|
121
|
+
'delicata squash',
|
|
122
|
+
'hubbard squash',
|
|
123
|
+
'hubbard',
|
|
124
|
+
'red kuri',
|
|
125
|
+
'squash',
|
|
126
|
+
'cargo pump',
|
|
127
|
+
'pumpkin',
|
|
128
|
+
'cucumber',
|
|
129
|
+
'pickle',
|
|
130
|
+
'shiso',
|
|
131
|
+
'shinto',
|
|
132
|
+
'thyme',
|
|
133
|
+
'rosemary',
|
|
134
|
+
'di lusia',
|
|
135
|
+
'di lusio',
|
|
136
|
+
'treviso',
|
|
137
|
+
'scallion',
|
|
138
|
+
'scalion',
|
|
139
|
+
'spring onion',
|
|
140
|
+
'springonion',
|
|
141
|
+
'onion',
|
|
142
|
+
'shallot',
|
|
143
|
+
'wasabi',
|
|
144
|
+
'lavendar',
|
|
145
|
+
'lavender',
|
|
146
|
+
'anise hyssop',
|
|
147
|
+
'alyssum',
|
|
148
|
+
'marjoram',
|
|
149
|
+
'mint',
|
|
150
|
+
'sorrel',
|
|
151
|
+
'tomato',
|
|
152
|
+
'grapes',
|
|
153
|
+
'apricot',
|
|
154
|
+
'peach',
|
|
155
|
+
'plum',
|
|
156
|
+
'blueberr',
|
|
157
|
+
'billberr',
|
|
158
|
+
'blackberr',
|
|
159
|
+
'raspberr',
|
|
160
|
+
'cloudberr',
|
|
161
|
+
'cloud berr',
|
|
162
|
+
'sweet pepper',
|
|
163
|
+
'bell pepper',
|
|
164
|
+
'strawberr',
|
|
165
|
+
'\\w*berr(?:y|ies)\\b',
|
|
166
|
+
'berry',
|
|
167
|
+
|
|
168
|
+
// Leave at end for backup
|
|
169
|
+
'marciano',
|
|
170
|
+
'spretnak',
|
|
171
|
+
'newham',
|
|
172
|
+
'bokchoy',
|
|
173
|
+
'bok choy',
|
|
174
|
+
'red butter',
|
|
175
|
+
'frisee',
|
|
176
|
+
'cresta',
|
|
177
|
+
'cardoon',
|
|
178
|
+
'cynara cardunculus',
|
|
179
|
+
'cardunculus',
|
|
180
|
+
'butternut',
|
|
181
|
+
'green gem',
|
|
182
|
+
'red gem',
|
|
183
|
+
'starry night',
|
|
184
|
+
'benning',
|
|
185
|
+
'summar savor',
|
|
186
|
+
'summer savor',
|
|
187
|
+
'summery savor',
|
|
188
|
+
'summary savor',
|
|
189
|
+
'delicata',
|
|
190
|
+
'matador',
|
|
191
|
+
'green curl',
|
|
192
|
+
'red oak',
|
|
193
|
+
'flower',
|
|
194
|
+
'yellow tooth',
|
|
195
|
+
'sage\\b',
|
|
196
|
+
'sages\\b',
|
|
197
|
+
'okra',
|
|
198
|
+
'flor\\b',
|
|
199
|
+
'gems\\b',
|
|
200
|
+
'pump\\b',
|
|
201
|
+
'cruced\\b',
|
|
202
|
+
'star\\b',
|
|
203
|
+
'stars\\b',
|
|
204
|
+
'seed',
|
|
205
|
+
'pepper',
|
|
206
|
+
'chilli',
|
|
207
|
+
'mix\\b',
|
|
208
|
+
'chard',
|
|
209
|
+
'nettle',
|
|
210
|
+
'savory',
|
|
211
|
+
'dino',
|
|
212
|
+
|
|
213
|
+
// log activities
|
|
214
|
+
// NOTE: If i18n words change, these have to change too
|
|
215
|
+
'soil',
|
|
216
|
+
'irrigation',
|
|
217
|
+
'fertilization',
|
|
218
|
+
'crop protection',
|
|
219
|
+
'crop monitoring',
|
|
220
|
+
'direct seed',
|
|
221
|
+
'pruning',
|
|
222
|
+
'trellising',
|
|
223
|
+
'preparing crops',
|
|
224
|
+
'crops',
|
|
225
|
+
'estimating yield',
|
|
226
|
+
'other harvest',
|
|
227
|
+
'grading produce',
|
|
228
|
+
'moving produce',
|
|
229
|
+
'cold storage temperature',
|
|
230
|
+
'post harvest',
|
|
231
|
+
'sale',
|
|
232
|
+
'water testing',
|
|
233
|
+
'chlorine level',
|
|
234
|
+
'field',
|
|
235
|
+
];
|
|
236
|
+
const ARABLE_ICON_BY_WORD = new Map(
|
|
237
|
+
ARABLE_ICON_WORD_GROUPS.flatMap(([iconName, words]) => words.map((word) => [normalizeIconMatchWord(word), iconName])),
|
|
238
|
+
);
|
|
239
|
+
const ARABLE_WORD_REGEX = new RegExp(`\\b(${ARABLE_ICON_PRIORITY_WORDS.join('|')})`, 'gi');
|
|
240
|
+
const ARABLE_ICON_PRIORITY_MATCHERS = ARABLE_ICON_PRIORITY_WORDS.map((word) => [word, new RegExp(`^${word}$`, 'i')] as const);
|
|
241
|
+
|
|
242
|
+
/*
|
|
243
|
+
* Normalize a matched icon word so regex-only word boundary markers do not affect map lookups.
|
|
244
|
+
*/
|
|
245
|
+
function normalizeIconMatchWord(word: string): string {
|
|
246
|
+
return word.replace(/\\b/g, '').toLowerCase();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
* Pick the highest-priority arable icon word from a list of regex matches.
|
|
251
|
+
*/
|
|
252
|
+
function getPreferredArableIconWord(matches: string[]): string {
|
|
253
|
+
if (matches.length === 1) {
|
|
254
|
+
const matchedPriorityWord = ARABLE_ICON_PRIORITY_MATCHERS.find(([, regex]) => regex.test(matches[0]))?.[0];
|
|
255
|
+
|
|
256
|
+
return normalizeIconMatchWord(matchedPriorityWord || matches[0]);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const preferredWord = ARABLE_ICON_PRIORITY_MATCHERS.find(([, regex]) => matches.some((match) => regex.test(match)))?.[0];
|
|
260
|
+
|
|
261
|
+
return preferredWord ? normalizeIconMatchWord(preferredWord) : normalizeIconMatchWord(matches[0]);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Get the icon name from crop name by using regex
|
|
266
|
+
* @param crop - The name of the crop
|
|
267
|
+
* @param note - Additional note that may contain crop type
|
|
268
|
+
* @param defaultIcon - The default icon to return if no match is found
|
|
269
|
+
* @returns The icon name or a default icon if no match is found
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
export function getIconNameForArable(crop?: string | undefined, note?: string | null, defaultIcon?: string): string {
|
|
273
|
+
if (crop) {
|
|
274
|
+
const match = crop.replace(/-/g, ' ').match(ARABLE_WORD_REGEX);
|
|
275
|
+
if (match) {
|
|
276
|
+
const matchedWord = getPreferredArableIconWord(match);
|
|
277
|
+
const iconName = ARABLE_ICON_BY_WORD.get(matchedWord);
|
|
278
|
+
|
|
279
|
+
if (iconName) {
|
|
280
|
+
return iconName;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
console.log('Missing icon lookup for crop:', crop);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// console.log('No match found for crop:', crop);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (note) {
|
|
290
|
+
return getIconNameForArable(note, null, defaultIcon);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return defaultIcon || 'seedling';
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get the icon name for farmers market using regex
|
|
298
|
+
* @param purchasedItem - The name of the purchased item
|
|
299
|
+
* @param note - Additional note that may contain livestock type
|
|
300
|
+
* @param defaultIcon - The default icon to return if no match is found
|
|
301
|
+
* @returns The icon name or a default icon if no match is found
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
export function getIconNameForFarmersMarket(
|
|
305
|
+
purchasedItem?: string | null,
|
|
306
|
+
note?: string | null,
|
|
307
|
+
defaultIcon?: string,
|
|
308
|
+
): string {
|
|
309
|
+
if (purchasedItem) {
|
|
310
|
+
// return 'seedling';
|
|
311
|
+
const FARMERS_MARKET_WORDS = [
|
|
312
|
+
'hay\\b',
|
|
313
|
+
'cow',
|
|
314
|
+
'calf',
|
|
315
|
+
'cattle',
|
|
316
|
+
'bull',
|
|
317
|
+
'sheep',
|
|
318
|
+
];
|
|
319
|
+
|
|
320
|
+
const regex = new RegExp(`\\b(${FARMERS_MARKET_WORDS.join('|')})`, 'gi');
|
|
321
|
+
const match = purchasedItem.replace('-', ' ').match(regex);
|
|
322
|
+
if (match) {
|
|
323
|
+
let matchedWord;
|
|
324
|
+
if (match.length === 1) {
|
|
325
|
+
matchedWord = match[0].toLowerCase();
|
|
326
|
+
} else {
|
|
327
|
+
// If multiple matches, choose the first match from produce words
|
|
328
|
+
const lcMatch = match.map((m) => m.toLowerCase());
|
|
329
|
+
matchedWord = FARMERS_MARKET_WORDS.find((word) => lcMatch.includes(word));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
switch (matchedWord) {
|
|
333
|
+
case 'hay':
|
|
334
|
+
return 'farming-hay';
|
|
335
|
+
case 'cow':
|
|
336
|
+
case 'calf':
|
|
337
|
+
case 'cattle':
|
|
338
|
+
case 'bull':
|
|
339
|
+
return 'livestock-cow-body';
|
|
340
|
+
default:
|
|
341
|
+
console.log('Missing switchcase for crop:', purchasedItem);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// console.log('No match found for farmers market:', purchasedItem);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (note) {
|
|
349
|
+
return getIconNameForFarmersMarket(note, null, defaultIcon);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return defaultIcon || 'farmers-market-kiosk';
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Get the icon name for grower network logs
|
|
357
|
+
* @param _item - The log item text
|
|
358
|
+
* @param _note - Additional note text
|
|
359
|
+
* @param _defaultIcon - The default icon to return if no match is found
|
|
360
|
+
* @returns The icon name or a default icon if no match is found
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
export function getIconNameForGrowerNetwork(
|
|
364
|
+
_item?: string | null,
|
|
365
|
+
_note?: string | null,
|
|
366
|
+
_defaultIcon?: string,
|
|
367
|
+
): string {
|
|
368
|
+
return 'circle';
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Get any icon name for any word
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
export function getIconNameForWord(
|
|
376
|
+
decidingWord: any,
|
|
377
|
+
text1: string,
|
|
378
|
+
text2?: string | null,
|
|
379
|
+
defaultIcon?: string,
|
|
380
|
+
) {
|
|
381
|
+
switch (decidingWord) {
|
|
382
|
+
case 'ARABLE':
|
|
383
|
+
case 'LogArable':
|
|
384
|
+
return getIconNameForArable(text1, text2, defaultIcon);
|
|
385
|
+
case 'FARMERS_MARKET':
|
|
386
|
+
case 'LogFarmersMarket':
|
|
387
|
+
return getIconNameForFarmersMarket(text1, text2, defaultIcon);
|
|
388
|
+
case 'GROWER_NETWORK':
|
|
389
|
+
case 'LogGrowerNetwork':
|
|
390
|
+
return getIconNameForGrowerNetwork(text1, text2, defaultIcon);
|
|
391
|
+
default:
|
|
392
|
+
}
|
|
393
|
+
return 'circle';
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Get icon name for any operation using regex
|
|
398
|
+
* @param details - GraphQL log details object
|
|
399
|
+
* @param defaultIcon - The default icon to return if no match is found
|
|
400
|
+
* @returns The icon name or a default icon if no match is found
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
export function getIconNameForLog(
|
|
404
|
+
details: any,
|
|
405
|
+
preferActivityText?: boolean,
|
|
406
|
+
defaultIcon_?: string,
|
|
407
|
+
) {
|
|
408
|
+
// "crop" is deprecation support -- it should be "item" going forward
|
|
409
|
+
const text1 = preferActivityText ? details.activity : details.item;
|
|
410
|
+
const text2 = preferActivityText ? (details.title + ' ' + details.notes) : details.notes;
|
|
411
|
+
// @ts-ignore - allow dynamic key access
|
|
412
|
+
const defaultIcon = (preferActivityText && COMMON_ICON_NAMES[details.activity]) || defaultIcon_;
|
|
413
|
+
|
|
414
|
+
// console.log('defaultIcon', preferActivityText, details.activity, defaultIcon);
|
|
415
|
+
|
|
416
|
+
return getIconNameForWord(details.__typename, text1, text2, defaultIcon);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Get title for log
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
export function getTitleForLog(details: any): string {
|
|
424
|
+
switch (details.__typename) {
|
|
425
|
+
case 'LogFarmersMarket':
|
|
426
|
+
{
|
|
427
|
+
// Check if text from values is short, else rely on the AI summary
|
|
428
|
+
const valuesText = (details.values || []).map((item: any) => {
|
|
429
|
+
return `${item.label} ${item.value ? formatCurrency(item.value, false) : ''}`.trim();
|
|
430
|
+
}).join(', ');
|
|
431
|
+
|
|
432
|
+
if (valuesText.length <= 40) {
|
|
433
|
+
return valuesText;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
break;
|
|
437
|
+
default:
|
|
438
|
+
}
|
|
439
|
+
return details.item;
|
|
440
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import type { OrganizationGQL } from '@jsb188/mday/types/organization.d.ts';
|
|
3
|
+
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get all title icons for organization/vendor
|
|
7
|
+
* @param org - Organization GQL data
|
|
8
|
+
* @param showIconsRule - Rules for which icons to show/not-show
|
|
9
|
+
* @returns Array of icon label objects with icon name and tooltip text
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export function getTitleIconsForOrganization(
|
|
13
|
+
org: OrganizationGQL,
|
|
14
|
+
showIconsRule: Record<string, boolean> = {},
|
|
15
|
+
) {
|
|
16
|
+
const { operation, compliance } = org;
|
|
17
|
+
const titleIcons = [];
|
|
18
|
+
|
|
19
|
+
if (operation && showIconsRule.operation !== false) {
|
|
20
|
+
titleIcons.push({
|
|
21
|
+
iconName: COMMON_ICON_NAMES[operation] || 'info-circle',
|
|
22
|
+
tooltipText: i18n.t(`org.type.${operation}`),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (compliance?.length && showIconsRule.compliance !== false) {
|
|
27
|
+
const today = new Date();
|
|
28
|
+
const todayCalDate = today.toISOString().split('T')[0];
|
|
29
|
+
const notExpired = compliance.filter((item: any) => item.expirationDate && item.expirationDate > todayCalDate);
|
|
30
|
+
|
|
31
|
+
if (notExpired.length > 0) {
|
|
32
|
+
titleIcons.push({
|
|
33
|
+
iconName: 'document-license',
|
|
34
|
+
tooltipText: notExpired.map((item: any) => item.name).join(', '),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return titleIcons;
|
|
40
|
+
}
|