@jsb188/mday-web 1.1.8 → 1.1.11

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.
@@ -0,0 +1,76 @@
1
+ import type { ServerErrorObj } from '@jsb188/app/types/app.d.ts';
2
+ import {
3
+ ContentGate,
4
+ ErrorMessage,
5
+ ErrorMessageContainer,
6
+ } from '@jsb188/react-web/modules/layout/MainLayout';
7
+ import { memo, type Dispatch, type SetStateAction } from 'react';
8
+
9
+ interface AppRouteShellProps {
10
+ layoutOpen: boolean;
11
+ setLayoutOpen: Dispatch<SetStateAction<boolean>>;
12
+ }
13
+
14
+ interface AppRouteErrorMessageProps extends AppRouteShellProps {
15
+ buttonColorClassName?: string;
16
+ buttonHref?: string;
17
+ buttonText?: string;
18
+ error?: ServerErrorObj | null;
19
+ iconName: string;
20
+ message: string;
21
+ title: string;
22
+ }
23
+
24
+ /*
25
+ * Render a reusable route error inside the app shell layout.
26
+ */
27
+ export const AppRouteErrorMessage = memo((p: AppRouteErrorMessageProps) => {
28
+ const {
29
+ buttonColorClassName,
30
+ buttonHref,
31
+ buttonText,
32
+ error,
33
+ iconName,
34
+ layoutOpen,
35
+ message,
36
+ setLayoutOpen,
37
+ title,
38
+ } = p;
39
+
40
+ return (
41
+ <ErrorMessageContainer
42
+ layoutOpen={layoutOpen}
43
+ setLayoutOpen={setLayoutOpen}
44
+ >
45
+ <ErrorMessage
46
+ buttonColorClassName={buttonColorClassName}
47
+ buttonHref={buttonHref}
48
+ buttonText={buttonText}
49
+ iconName={iconName}
50
+ title={title}
51
+ message={message}
52
+ {...error}
53
+ />
54
+ </ErrorMessageContainer>
55
+ );
56
+ });
57
+
58
+ AppRouteErrorMessage.displayName = 'AppRouteErrorMessage';
59
+
60
+ /*
61
+ * Render a reusable app-shell loading state while route data is being fetched.
62
+ */
63
+ export const AppRouteLoading = memo((p: AppRouteShellProps) => {
64
+ const { layoutOpen, setLayoutOpen } = p;
65
+
66
+ return (
67
+ <ErrorMessageContainer
68
+ layoutOpen={layoutOpen}
69
+ setLayoutOpen={setLayoutOpen}
70
+ >
71
+ <ContentGate loading notReady showLoadingIfNotReady />
72
+ </ErrorMessageContainer>
73
+ );
74
+ });
75
+
76
+ AppRouteLoading.displayName = 'AppRouteLoading';
@@ -0,0 +1 @@
1
+ declare module '*.css';
@@ -0,0 +1,64 @@
1
+ import i18n from '@jsb188/app/i18n/index.ts';
2
+ import { getTimeZoneCode } from '@jsb188/app/utils/timeZone.ts';
3
+ import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
4
+
5
+ /*
6
+ * Build the shared current-account menu options used by app navigation controls.
7
+ */
8
+ export function getMarketdayAccountOptions(p: {
9
+ avatarClassName?: string;
10
+ fullName: string;
11
+ onSignOut: () => void;
12
+ profileLabel: string;
13
+ profilePhotoUri: string | null;
14
+ timeZone: string | null;
15
+ }) {
16
+ const {
17
+ avatarClassName,
18
+ fullName,
19
+ onSignOut,
20
+ profileLabel,
21
+ profilePhotoUri,
22
+ timeZone,
23
+ } = p;
24
+ const timeZoneCode = getTimeZoneCode(timeZone, true);
25
+
26
+ return [
27
+ {
28
+ __type: 'AVATAR_ITEM' as const,
29
+ avatarDisplayName: fullName,
30
+ className: avatarClassName,
31
+ photoUri: profilePhotoUri,
32
+ text: fullName,
33
+ label: profileLabel,
34
+ },
35
+ {
36
+ __type: 'BREAK' as const,
37
+ },
38
+ {
39
+ __type: 'LIST_ITEM_MODAL' as const,
40
+ iconName: COMMON_ICON_NAMES.account_profile,
41
+ variables: {
42
+ name: 'ACCOUNT_INFO',
43
+ },
44
+ text: i18n.t('account.your_account'),
45
+ },
46
+ {
47
+ __type: 'BREAK' as const,
48
+ },
49
+ {
50
+ __type: 'TEXT' as const,
51
+ text: i18n.t('app.timezone_set_to_', { timeZone: timeZoneCode }),
52
+ },
53
+ {
54
+ __type: 'BREAK' as const,
55
+ },
56
+ {
57
+ __type: 'LIST_ITEM' as const,
58
+ onClick: onSignOut,
59
+ preset: 'small' as const,
60
+ text: i18n.t('auth.sign_out'),
61
+ value: true,
62
+ },
63
+ ];
64
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Map nullable list records into renderable list items in one pass.
3
+ */
4
+ export function mapRenderableItems<T, R>(
5
+ items: T[] | null | undefined,
6
+ mapItem: (item: T) => R | null | undefined,
7
+ ) {
8
+ return (items ?? []).reduce<NonNullable<R>[]>((acc, item) => {
9
+ const mappedItem = mapItem(item);
10
+
11
+ if (mappedItem != null) {
12
+ acc.push(mappedItem);
13
+ }
14
+
15
+ return acc;
16
+ }, []);
17
+ }
@@ -0,0 +1,550 @@
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
+ [
6
+ 'vegetable-lettuce-top',
7
+ [
8
+ 'little gem',
9
+ 'lil gem',
10
+ 'marciano',
11
+ 'red butter',
12
+ 'green gem',
13
+ 'red gem',
14
+ 'gems\\b',
15
+ 'spretnak',
16
+ 'newham',
17
+ 'bokchoy',
18
+ 'bok choy',
19
+ ],
20
+ ],
21
+ [
22
+ 'vegetable-lettuce',
23
+ [
24
+ 'lettuce',
25
+ 'red oak',
26
+ 'romaine',
27
+ 'escarol',
28
+ 'radicchio',
29
+ 'braci ardenti',
30
+ 'braci adenti',
31
+ 'di lusia',
32
+ 'di lusio',
33
+ 'treviso',
34
+ 'thaddeus',
35
+ 'cruced\\b',
36
+ ],
37
+ ],
38
+ ['vegetable-lavender', ['lavendar', 'lavender', 'anise hyssop', 'alyssum']],
39
+ ['vegetable-basil', ['basil']],
40
+ ['vegetable-beet', ['chioggia', 'beet', 'yellow tooth']],
41
+ ['vegetable-broccoli', ['cauliflow', 'broccoli', 'piracicab']],
42
+ [
43
+ 'vegetable-pumpkin',
44
+ ['pumpkin', 'pump\\b', 'cargo pump', 'bennings green', 'benning'],
45
+ ],
46
+ [
47
+ 'vegetable-spinach',
48
+ ['mesclun', 'spinach', 'chard', 'mustard green', 'mix\\b'],
49
+ ],
50
+ ['vegetable-tomato', ['tomato']],
51
+ ['fruit-grapes', ['grapes']],
52
+ ['fruit-apricot', ['apricot', 'peach', 'plum']],
53
+ ['raspberry', ['raspberr']],
54
+ ['fruit-cloud-berry', ['blackberr', 'cloudberr', 'cloud berr']],
55
+ [
56
+ 'fruit-billberry-blackberry-blueberry',
57
+ ['blueberr', 'billberr', 'berry', '\\w*berr(?:y|ies)\\b'],
58
+ ],
59
+ ['vegetable-asparagus', ['asparagus']],
60
+ [
61
+ 'vegetable-acornsquash',
62
+ [
63
+ 'sunshine kabocha',
64
+ 'acorn squash',
65
+ 'acornsquash',
66
+ 'yellow star patty',
67
+ 'sweet pepper',
68
+ 'bell pepper',
69
+ ],
70
+ ],
71
+ ['fruit-strawberry', ['strawberr']], // commented now for testing
72
+ ['seasoning-chilli', ['pepper', 'chilli']],
73
+ ['vegetable-delicata-squash', ['delicata', 'delicata squash']],
74
+ ['vegetable-hubbard-squash', ['hubbard squash', 'hubbard', 'red kuri']],
75
+ ['vegetable-cucumber', ['shinto', 'cucumber', 'pickle']],
76
+ [
77
+ 'vegetable-butternutsquash',
78
+ [
79
+ 'butternut squash',
80
+ 'butternutsquash',
81
+ 'butternut',
82
+ 'squash',
83
+ 'starry night',
84
+ ],
85
+ ],
86
+ [
87
+ 'vegetable-thyme',
88
+ [
89
+ 'summar savor',
90
+ 'summer savor',
91
+ 'summery savor',
92
+ 'summary savor',
93
+ 'thyme',
94
+ 'rosemary',
95
+ 'savory',
96
+ ],
97
+ ],
98
+ [
99
+ 'vegetable-arugula',
100
+ [
101
+ 'arugula',
102
+ 'chicory',
103
+ 'puntarelle',
104
+ 'frisee',
105
+ 'kale',
106
+ 'dino',
107
+ 'green curl',
108
+ ],
109
+ ],
110
+ ['vegetable-parsley', ['parsley', 'beoc raab', 'wasabina', 'chervil']],
111
+ ['vegetable-carrot', ['carrot']],
112
+ ['vegetable-artichoke', ['artichoke', 'romanesco', 'star\\b', 'stars\\b']],
113
+ ['vegetable-cabbage', ['cabbag']],
114
+ ['vegetable-kohlrabi', ['kohlrab']],
115
+ ['vegetable-zucchini', ['zucchini', 'zuchini', 'midnight light']],
116
+ ['vegetable-potato', ['potato']],
117
+ ['vegetable-eggplant', ['eggplant']],
118
+ ['vegetable-jalapeno', ['jalapeno', 'jalapeño']],
119
+ [
120
+ 'vegetable-stinging-kettle',
121
+ [
122
+ 'stinging kettle',
123
+ 'nettle',
124
+ 'cardoon',
125
+ 'cynara cardunculus',
126
+ 'cardunculus',
127
+ 'cresta',
128
+ 'shiso',
129
+ ],
130
+ ],
131
+ ['vegetable-okra', ['okra']],
132
+ ['plant-1', ['sage\\b', 'sages\\b', 'marjoram', 'sorrel', 'mint']],
133
+ [
134
+ 'vegetable-scallion',
135
+ ['scallion', 'scalion', 'spring onion', 'springonion'],
136
+ ],
137
+ ['gardening-seed-bag', ['seed']],
138
+ ['vegetable-onion', ['onion', 'shallot', 'matador']],
139
+ ['vegetable-black-bean', ['oliv']],
140
+ ['vegetable-stringbean-1', ['bean', 'stringbean']],
141
+ ['vegetable-cilantro', ['cilantro', 'flor\\b']],
142
+ ['vegetable-radish', ['raddish', 'radish']],
143
+ ['vegetable-wasabi', ['wasabi']],
144
+ ['flower', ['flower']],
145
+ ['product-growth-tree-box', ['soil']],
146
+ ['gardening-sprinkler', ['irrigation']],
147
+ ['agriculture-machine-seeder', ['direct seed']],
148
+ ['organic-bag-leaf', ['fertilization']],
149
+ ['gardening-tools-1', ['crop protection']],
150
+ ['farming-barn-sun', ['crop monitoring', 'field']],
151
+ ['gardening-scissors', ['pruning']],
152
+ ['barbed-wire-fence', ['trellising']],
153
+ ['protein-gluten-wheat', ['preparing crops']],
154
+ ['harvest-product', ['crops', 'grading produce', 'moving produce']],
155
+ ['crop-info-biotech-1', ['estimating yield', 'other harvest']],
156
+ ['warehouse-storage', ['post harvest']],
157
+ ['temperature-control-warehouse-1', ['cold storage temperature']],
158
+ ['receipt-dollar', ['sale']],
159
+ ['organic-flask', ['water testing', 'chlorine level']],
160
+ ];
161
+
162
+ const ARABLE_ICON_PRIORITY_WORDS = [
163
+ 'little gem',
164
+ 'lil gem',
165
+ 'romaine',
166
+ 'cauliflow',
167
+ 'broccoli',
168
+ 'piracicab',
169
+ 'mesclun',
170
+ 'spinach',
171
+ 'mustard green',
172
+ 'arugula',
173
+ 'kale',
174
+ 'kohlrab',
175
+ 'cabbag',
176
+ 'parsley',
177
+ 'beoc raab',
178
+ 'wasabina',
179
+ 'chervil',
180
+ 'basil',
181
+ 'artichoke',
182
+ 'romanesco',
183
+ 'zucchini',
184
+ 'zuchini',
185
+ 'potato',
186
+ 'eggplant',
187
+ 'jalapeno',
188
+ 'jalapeño',
189
+ 'carrot',
190
+ 'midnight light',
191
+ 'cilantro',
192
+ 'bennings green',
193
+ 'lettuce',
194
+ 'escarol',
195
+ 'raddish',
196
+ 'radish',
197
+ 'bean',
198
+ 'stringbean',
199
+ 'oliv',
200
+ 'stinging kettle',
201
+ 'radicchio',
202
+ 'braci ardenti',
203
+ 'braci adenti',
204
+ 'chicory',
205
+ 'puntarelle',
206
+ 'chioggia',
207
+ 'beet',
208
+ 'thaddeus',
209
+ 'sunshine kabocha',
210
+ 'yellow star patty',
211
+ 'butternut squash',
212
+ 'butternutsquash',
213
+ 'asparagus',
214
+ 'acorn squash',
215
+ 'acornsquash',
216
+ 'delicata squash',
217
+ 'hubbard squash',
218
+ 'hubbard',
219
+ 'red kuri',
220
+ 'squash',
221
+ 'cargo pump',
222
+ 'pumpkin',
223
+ 'cucumber',
224
+ 'pickle',
225
+ 'shiso',
226
+ 'shinto',
227
+ 'thyme',
228
+ 'rosemary',
229
+ 'di lusia',
230
+ 'di lusio',
231
+ 'treviso',
232
+ 'scallion',
233
+ 'scalion',
234
+ 'spring onion',
235
+ 'springonion',
236
+ 'onion',
237
+ 'shallot',
238
+ 'wasabi',
239
+ 'lavendar',
240
+ 'lavender',
241
+ 'anise hyssop',
242
+ 'alyssum',
243
+ 'marjoram',
244
+ 'mint',
245
+ 'sorrel',
246
+ 'tomato',
247
+ 'grapes',
248
+ 'apricot',
249
+ 'peach',
250
+ 'plum',
251
+ 'blueberr',
252
+ 'billberr',
253
+ 'blackberr',
254
+ 'raspberr',
255
+ 'cloudberr',
256
+ 'cloud berr',
257
+ 'sweet pepper',
258
+ 'bell pepper',
259
+ 'strawberr',
260
+ '\\w*berr(?:y|ies)\\b',
261
+ 'berry',
262
+
263
+ // Leave at end for backup
264
+ 'marciano',
265
+ 'spretnak',
266
+ 'newham',
267
+ 'bokchoy',
268
+ 'bok choy',
269
+ 'red butter',
270
+ 'frisee',
271
+ 'cresta',
272
+ 'cardoon',
273
+ 'cynara cardunculus',
274
+ 'cardunculus',
275
+ 'butternut',
276
+ 'green gem',
277
+ 'red gem',
278
+ 'starry night',
279
+ 'benning',
280
+ 'summar savor',
281
+ 'summer savor',
282
+ 'summery savor',
283
+ 'summary savor',
284
+ 'delicata',
285
+ 'matador',
286
+ 'green curl',
287
+ 'red oak',
288
+ 'flower',
289
+ 'yellow tooth',
290
+ 'sage\\b',
291
+ 'sages\\b',
292
+ 'okra',
293
+ 'flor\\b',
294
+ 'gems\\b',
295
+ 'pump\\b',
296
+ 'cruced\\b',
297
+ 'star\\b',
298
+ 'stars\\b',
299
+ 'seed',
300
+ 'pepper',
301
+ 'chilli',
302
+ 'mix\\b',
303
+ 'chard',
304
+ 'nettle',
305
+ 'savory',
306
+ 'dino',
307
+
308
+ // log activities
309
+ // NOTE: If i18n words change, these have to change too
310
+ 'soil',
311
+ 'irrigation',
312
+ 'fertilization',
313
+ 'crop protection',
314
+ 'crop monitoring',
315
+ 'direct seed',
316
+ 'pruning',
317
+ 'trellising',
318
+ 'preparing crops',
319
+ 'crops',
320
+ 'estimating yield',
321
+ 'other harvest',
322
+ 'grading produce',
323
+ 'moving produce',
324
+ 'cold storage temperature',
325
+ 'post harvest',
326
+ 'sale',
327
+ 'water testing',
328
+ 'chlorine level',
329
+ 'field',
330
+ ];
331
+ const ARABLE_ICON_BY_WORD = new Map(
332
+ ARABLE_ICON_WORD_GROUPS.flatMap(([iconName, words]) =>
333
+ words.map((word) => [normalizeIconMatchWord(word), iconName]),
334
+ ),
335
+ );
336
+ const ARABLE_WORD_REGEX = new RegExp(
337
+ `\\b(${ARABLE_ICON_PRIORITY_WORDS.join('|')})`,
338
+ 'gi',
339
+ );
340
+ const ARABLE_ICON_PRIORITY_MATCHERS = ARABLE_ICON_PRIORITY_WORDS.map(
341
+ (word) => [word, new RegExp(`^${word}$`, 'i')] as const,
342
+ );
343
+
344
+ /*
345
+ * Normalize a matched icon word so regex-only word boundary markers do not affect map lookups.
346
+ */
347
+ function normalizeIconMatchWord(word: string): string {
348
+ return word.replace(/\\b/g, '').toLowerCase();
349
+ }
350
+
351
+ /*
352
+ * Pick the highest-priority arable icon word from a list of regex matches.
353
+ */
354
+ function getPreferredArableIconWord(matches: string[]): string {
355
+ if (matches.length === 1) {
356
+ const matchedPriorityWord = ARABLE_ICON_PRIORITY_MATCHERS.find(
357
+ ([, regex]) => regex.test(matches[0]),
358
+ )?.[0];
359
+
360
+ return normalizeIconMatchWord(matchedPriorityWord || matches[0]);
361
+ }
362
+
363
+ const preferredWord = ARABLE_ICON_PRIORITY_MATCHERS.find(([, regex]) =>
364
+ matches.some((match) => regex.test(match)),
365
+ )?.[0];
366
+
367
+ return preferredWord
368
+ ? normalizeIconMatchWord(preferredWord)
369
+ : normalizeIconMatchWord(matches[0]);
370
+ }
371
+
372
+ /**
373
+ * Get the icon name from crop name by using regex
374
+ * @param crop - The name of the crop
375
+ * @param note - Additional note that may contain crop type
376
+ * @param defaultIcon - The default icon to return if no match is found
377
+ * @returns The icon name or a default icon if no match is found
378
+ */
379
+
380
+ export function getIconNameForArable(
381
+ crop?: string | undefined,
382
+ note?: string | null,
383
+ defaultIcon?: string,
384
+ ): string {
385
+ if (crop) {
386
+ const match = crop.replace(/-/g, ' ').match(ARABLE_WORD_REGEX);
387
+ if (match) {
388
+ const matchedWord = getPreferredArableIconWord(match);
389
+ const iconName = ARABLE_ICON_BY_WORD.get(matchedWord);
390
+
391
+ if (iconName) {
392
+ return iconName;
393
+ }
394
+
395
+ console.log('Missing icon lookup for crop:', crop);
396
+ }
397
+
398
+ // console.log('No match found for crop:', crop);
399
+ }
400
+
401
+ if (note) {
402
+ return getIconNameForArable(note, null, defaultIcon);
403
+ }
404
+
405
+ return defaultIcon || 'seedling';
406
+ }
407
+
408
+ /**
409
+ * Get the icon name for farmers market using regex
410
+ * @param purchasedItem - The name of the purchased item
411
+ * @param note - Additional note that may contain a market item type
412
+ * @param defaultIcon - The default icon to return if no match is found
413
+ * @returns The icon name or a default icon if no match is found
414
+ */
415
+
416
+ export function getIconNameForFarmersMarket(
417
+ purchasedItem?: string | null,
418
+ note?: string | null,
419
+ defaultIcon?: string,
420
+ ): string {
421
+ if (purchasedItem) {
422
+ // return 'seedling';
423
+ const FARMERS_MARKET_WORDS = ['hay\\b'];
424
+
425
+ const regex = new RegExp(`\\b(${FARMERS_MARKET_WORDS.join('|')})`, 'gi');
426
+ const match = purchasedItem.replace('-', ' ').match(regex);
427
+ if (match) {
428
+ let matchedWord: string | undefined;
429
+ if (match.length === 1) {
430
+ matchedWord = match[0].toLowerCase();
431
+ } else {
432
+ // If multiple matches, choose the first match from produce words
433
+ const lcMatch = match.map((m) => m.toLowerCase());
434
+ matchedWord = FARMERS_MARKET_WORDS.find((word) =>
435
+ lcMatch.includes(word),
436
+ );
437
+ }
438
+
439
+ switch (matchedWord) {
440
+ case 'hay':
441
+ return 'farming-hay';
442
+ default:
443
+ console.log('Missing switchcase for crop:', purchasedItem);
444
+ }
445
+ }
446
+
447
+ // console.log('No match found for farmers market:', purchasedItem);
448
+ }
449
+
450
+ if (note) {
451
+ return getIconNameForFarmersMarket(note, null, defaultIcon);
452
+ }
453
+
454
+ return defaultIcon || 'farmers-market-kiosk';
455
+ }
456
+
457
+ /**
458
+ * Get the icon name for grower network logs
459
+ * @param _item - The log item text
460
+ * @param _note - Additional note text
461
+ * @param _defaultIcon - The default icon to return if no match is found
462
+ * @returns The icon name or a default icon if no match is found
463
+ */
464
+
465
+ export function getIconNameForGrowerNetwork(
466
+ _item?: string | null,
467
+ _note?: string | null,
468
+ _defaultIcon?: string,
469
+ ): string {
470
+ return 'circle';
471
+ }
472
+
473
+ /**
474
+ * Get any icon name for any word
475
+ */
476
+
477
+ export function getIconNameForWord(
478
+ decidingWord: any,
479
+ text1: string,
480
+ text2?: string | null,
481
+ defaultIcon?: string,
482
+ ) {
483
+ switch (decidingWord) {
484
+ case 'ARABLE':
485
+ return getIconNameForArable(text1, text2, defaultIcon);
486
+ case 'FARMERS_MARKET':
487
+ return getIconNameForFarmersMarket(text1, text2, defaultIcon);
488
+ case 'GROWER_NETWORK':
489
+ return getIconNameForGrowerNetwork(text1, text2, defaultIcon);
490
+ default:
491
+ }
492
+ return 'circle';
493
+ }
494
+
495
+ /**
496
+ * Get icon name for any operation using regex
497
+ * @param details - GraphQL log details object
498
+ * @param defaultIcon - The default icon to return if no match is found
499
+ * @returns The icon name or a default icon if no match is found
500
+ */
501
+
502
+ export function getIconNameForLog(
503
+ details: any,
504
+ preferActivityText?: boolean,
505
+ defaultIcon_?: string,
506
+ ) {
507
+ // "crop" is deprecation support -- it should be "item" going forward
508
+ const text1 = preferActivityText ? details.activity : details.item;
509
+ const text2 = preferActivityText
510
+ ? details.title + ' ' + details.notes
511
+ : details.notes;
512
+ // @ts-ignore - allow dynamic key access
513
+ const defaultIcon =
514
+ (preferActivityText && COMMON_ICON_NAMES[details.activity]) || defaultIcon_;
515
+
516
+ // console.log('defaultIcon', preferActivityText, details.activity, defaultIcon);
517
+
518
+ const operation = String(details.type || '').startsWith('MARKET_')
519
+ ? 'FARMERS_MARKET'
520
+ : ['WORKER_PRACTICE', 'PRODUCTION_INPUT'].includes(details.type)
521
+ ? 'GROWER_NETWORK'
522
+ : 'ARABLE';
523
+
524
+ return getIconNameForWord(operation, text1, text2, defaultIcon);
525
+ }
526
+
527
+ /**
528
+ * Get title for log
529
+ */
530
+
531
+ export function getTitleForLog(details: any): string {
532
+ switch (details.type) {
533
+ case 'MARKET_RECEIPT':
534
+ {
535
+ // Check if text from values is short, else rely on the AI summary
536
+ const valuesText = (details.values || [])
537
+ .map((item: any) => {
538
+ return `${item.label} ${item.value ? formatCurrency(item.value, false) : ''}`.trim();
539
+ })
540
+ .join(', ');
541
+
542
+ if (valuesText.length <= 40) {
543
+ return valuesText;
544
+ }
545
+ }
546
+ break;
547
+ default:
548
+ }
549
+ return details.item;
550
+ }