@jsb188/mday 1.1.7 → 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 +39 -20
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/email.ts +28 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +14 -0
- package/src/constants/log-activityTexts.ts +54 -28
- package/src/constants/log.ts +82 -38
- package/src/constants/organization.ts +11 -2
- package/src/constants/product.ts +9 -33
- package/src/constants/report.ts +29 -10
- package/src/constants/sheet.ts +20 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +12 -0
- package/src/schemas/editLogEntry.ts +90 -44
- package/src/schemas/inboundContact.ts +72 -0
- package/src/schemas/logsQuery.ts +7 -272
- package/src/schemas/organization.ts +11 -174
- package/src/schemas/productsQuery.ts +2 -94
- package/src/schemas/reportsQuery.ts +8 -95
- package/src/types/account.d.ts +78 -0
- package/src/types/dataTable.d.ts +447 -0
- package/src/types/email.d.ts +71 -0
- package/src/types/inboundContact.d.ts +56 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +289 -178
- package/src/types/organization.d.ts +106 -50
- package/src/types/product.d.ts +7 -96
- package/src/types/report.d.ts +239 -152
- package/src/types/sheet.d.ts +298 -0
- package/src/types/storage.d.ts +161 -0
- package/src/types/workflow.d.ts +174 -0
- package/src/utils/dataTable.ts +834 -0
- package/src/utils/email.ts +113 -0
- package/src/utils/log.ts +30 -628
- package/src/utils/organization.ts +227 -44
- package/src/utils/product-calEvent.ts +7 -60
- package/src/utils/report.ts +158 -0
- package/src/utils/sheet.ts +170 -0
- package/src/utils/square.ts +22 -0
- package/src/utils/table-route.ts +146 -0
- package/src/utils/workflow.ts +212 -0
- package/tsconfig.json +12 -0
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/types/action.d.ts +0 -42
- package/src/utils/route-helpers.ts +0 -583
package/src/utils/log.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import i18n from '@jsb188/app/i18n';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { formatReferenceNumber, joinReadable, textWithBrackets, ucFirst } from '@jsb188/app/utils/string';
|
|
5
|
-
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import { formatCurrency, formatDecimal } from '@jsb188/app/utils/number.ts';
|
|
3
|
+
import { formatReferenceNumber, joinReadable, textWithBrackets, ucFirst } from '@jsb188/app/utils/string.ts';
|
|
6
4
|
import {
|
|
7
5
|
ARABLE_ACTIVITIES_GROUPED,
|
|
8
6
|
FARMERS_MARKET_ACTIVITIES_GROUPED,
|
|
7
|
+
GROWER_NETWORK_ACTIVITIES_GROUPED,
|
|
9
8
|
LIVESTOCK_ACTIVITIES_GROUPED,
|
|
10
9
|
LOG_TYPES_BY_OPERATION
|
|
11
|
-
} from '../constants/log';
|
|
12
|
-
import type { LogEntryData, LogTypeEnum
|
|
10
|
+
} from '../constants/log.ts';
|
|
11
|
+
import type { LogContentName, LogEntryData, LogTypeEnum } from '../types/log.d.ts';
|
|
12
|
+
import type { OrganizationOperationEnum } from '../types/organization.d.ts';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Get content type for log by activity
|
|
@@ -61,13 +61,18 @@ export function getLogCategoryColor(type: LogTypeEnum) {
|
|
|
61
61
|
// #### ARABLE - Food Safety
|
|
62
62
|
HYGIENE: 'teal',
|
|
63
63
|
SANITATION: 'sky',
|
|
64
|
-
|
|
64
|
+
EQUIPMENT: 'indigo',
|
|
65
65
|
BIOSECURITY: 'green',
|
|
66
|
-
|
|
66
|
+
EMPLOYEE: 'yellow',
|
|
67
67
|
|
|
68
68
|
// #### FARMERS_MARKET
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
MARKET_RECEIPT: 'blue',
|
|
70
|
+
MARKET_OPERATION: 'rose',
|
|
71
|
+
|
|
72
|
+
// #### GROWER_NETWORK
|
|
73
|
+
WORKER_PRACTICE: 'purple',
|
|
74
|
+
PRODUCTION_INPUT: 'sky',
|
|
75
|
+
OPERATION: 'yellow',
|
|
71
76
|
|
|
72
77
|
// #### LIVESTOCK
|
|
73
78
|
SUPPLY_PURCHASE: 'brown',
|
|
@@ -76,9 +81,6 @@ export function getLogCategoryColor(type: LogTypeEnum) {
|
|
|
76
81
|
PASTURE_LAND_MANAGEMENT: 'green',
|
|
77
82
|
LIVESTOCK_HEALTHCARE: 'teal',
|
|
78
83
|
LIVESTOCK_SALE: 'blue',
|
|
79
|
-
|
|
80
|
-
// #### Merged into every operation
|
|
81
|
-
AI_TASK: 'slate',
|
|
82
84
|
} as Record<LogTypeEnum, string>;
|
|
83
85
|
|
|
84
86
|
// Default to zinc if type is not found
|
|
@@ -92,12 +94,9 @@ export function getLogCategoryColor(type: LogTypeEnum) {
|
|
|
92
94
|
* @returns Array of log types for the operation
|
|
93
95
|
*/
|
|
94
96
|
|
|
95
|
-
export function getLogTypesForOperation(operation: OrganizationOperationEnum
|
|
97
|
+
export function getLogTypesForOperation(operation: OrganizationOperationEnum): LogTypeEnum[] {
|
|
96
98
|
const logTypes = (LOG_TYPES_BY_OPERATION[operation] || []) as LogTypeEnum[];
|
|
97
|
-
|
|
98
|
-
return logTypes;
|
|
99
|
-
}
|
|
100
|
-
return logTypes.filter((type) => type !== 'AI_TASK');
|
|
99
|
+
return logTypes;
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
/**
|
|
@@ -122,6 +121,10 @@ export function getLogTypeFromActivity(operation: OrganizationOperationEnum | st
|
|
|
122
121
|
case 'LogFarmersMarket':
|
|
123
122
|
logGroup = FARMERS_MARKET_ACTIVITIES_GROUPED.find((group: any) => group[1].includes(activity));
|
|
124
123
|
break;
|
|
124
|
+
case 'GROWER_NETWORK':
|
|
125
|
+
case 'LogGrowerNetwork':
|
|
126
|
+
logGroup = GROWER_NETWORK_ACTIVITIES_GROUPED.find((group: any) => group[1].includes(activity));
|
|
127
|
+
break;
|
|
125
128
|
default:
|
|
126
129
|
console.warn('(!1) Cannot get log type from unknown operation type:', operation);
|
|
127
130
|
return null;
|
|
@@ -203,6 +206,14 @@ export function getLogEntryTitle(d: any, isServer?: boolean, logType_?: string,
|
|
|
203
206
|
const voidText = isServer && md.voided ? i18n.t('form.void').toUpperCase() : '';
|
|
204
207
|
return `${creditsText && voidText ? '(' + voidText + ')' : voidText} ${creditsText}`.trim();
|
|
205
208
|
}
|
|
209
|
+
case 'GROWER_NETWORK':
|
|
210
|
+
case 'logs_grower_network':
|
|
211
|
+
case 'LogGrowerNetwork':
|
|
212
|
+
return textWithBrackets(
|
|
213
|
+
ucFirst(md.item),
|
|
214
|
+
md.location,
|
|
215
|
+
[' - ', ''],
|
|
216
|
+
);
|
|
206
217
|
case 'LIVESTOCK':
|
|
207
218
|
case 'logs_livestock':
|
|
208
219
|
case 'LogLivestock': {
|
|
@@ -260,612 +271,3 @@ export function getTextFormatLog(log: LogEntryData) {
|
|
|
260
271
|
const title = getLogEntryTitle(log.details || {}, true);
|
|
261
272
|
return (title + '\n\n' + (notes + '')).trim();
|
|
262
273
|
}
|
|
263
|
-
|
|
264
|
-
const PRODUCE_WORDS = [
|
|
265
|
-
'little gem',
|
|
266
|
-
'lil gem',
|
|
267
|
-
'romaine',
|
|
268
|
-
'cauliflow',
|
|
269
|
-
'broccoli',
|
|
270
|
-
'piracicab',
|
|
271
|
-
'mesclun',
|
|
272
|
-
'spinach',
|
|
273
|
-
'mustard green',
|
|
274
|
-
'arugula',
|
|
275
|
-
'kale',
|
|
276
|
-
'kohlrab',
|
|
277
|
-
'cabbag',
|
|
278
|
-
'parsley',
|
|
279
|
-
'beoc raab',
|
|
280
|
-
'wasabina',
|
|
281
|
-
'chervil',
|
|
282
|
-
'basil',
|
|
283
|
-
'artichoke',
|
|
284
|
-
'romanesco',
|
|
285
|
-
'zucchini',
|
|
286
|
-
'zuchini',
|
|
287
|
-
'potato',
|
|
288
|
-
'eggplant',
|
|
289
|
-
'jalapeno',
|
|
290
|
-
'jalapeño',
|
|
291
|
-
'carrot',
|
|
292
|
-
'midnight light',
|
|
293
|
-
'cilantro',
|
|
294
|
-
'bennings green',
|
|
295
|
-
'lettuce',
|
|
296
|
-
'escarol',
|
|
297
|
-
'raddish',
|
|
298
|
-
'radish',
|
|
299
|
-
'bean',
|
|
300
|
-
'stringbean',
|
|
301
|
-
'stinging kettle',
|
|
302
|
-
'radicchio',
|
|
303
|
-
'braci ardenti',
|
|
304
|
-
'braci adenti',
|
|
305
|
-
'chicory',
|
|
306
|
-
'puntarelle',
|
|
307
|
-
'chioggia',
|
|
308
|
-
'beet',
|
|
309
|
-
'thaddeus',
|
|
310
|
-
'sunshine kabocha',
|
|
311
|
-
'yellow star patty',
|
|
312
|
-
'butternut squash',
|
|
313
|
-
'butternutsquash',
|
|
314
|
-
'asparagus',
|
|
315
|
-
'acorn squash',
|
|
316
|
-
'acornsquash',
|
|
317
|
-
'delicata squash',
|
|
318
|
-
'hubbard squash',
|
|
319
|
-
'hubbard',
|
|
320
|
-
'red kuri',
|
|
321
|
-
'squash',
|
|
322
|
-
'cargo pump',
|
|
323
|
-
'pumpkin',
|
|
324
|
-
'cucumber',
|
|
325
|
-
'shiso',
|
|
326
|
-
'shinto',
|
|
327
|
-
'thyme',
|
|
328
|
-
'rosemary',
|
|
329
|
-
'di lusia',
|
|
330
|
-
'di lusio',
|
|
331
|
-
'treviso',
|
|
332
|
-
'scallion',
|
|
333
|
-
'scalion',
|
|
334
|
-
'spring onion',
|
|
335
|
-
'springonion',
|
|
336
|
-
'onion',
|
|
337
|
-
'shallot',
|
|
338
|
-
'wasabi',
|
|
339
|
-
'lavendar',
|
|
340
|
-
'lavender',
|
|
341
|
-
'anise hyssop',
|
|
342
|
-
'alyssum',
|
|
343
|
-
'marjoram',
|
|
344
|
-
'mint',
|
|
345
|
-
'sorrel',
|
|
346
|
-
'tomato',
|
|
347
|
-
'grapes',
|
|
348
|
-
'apricot',
|
|
349
|
-
'peach',
|
|
350
|
-
'plum',
|
|
351
|
-
'blueberr',
|
|
352
|
-
'billberr',
|
|
353
|
-
'blackberr',
|
|
354
|
-
'raspberr',
|
|
355
|
-
'cloudberr',
|
|
356
|
-
'cloud berr',
|
|
357
|
-
'sweet pepper',
|
|
358
|
-
'bell pepper',
|
|
359
|
-
'strawberr',
|
|
360
|
-
'berry',
|
|
361
|
-
|
|
362
|
-
// Leave at end for backup
|
|
363
|
-
'marciano',
|
|
364
|
-
'spretnak',
|
|
365
|
-
'newham',
|
|
366
|
-
'red butter',
|
|
367
|
-
'frisee',
|
|
368
|
-
'cresta',
|
|
369
|
-
'cardoon',
|
|
370
|
-
'cynara cardunculus',
|
|
371
|
-
'cardunculus',
|
|
372
|
-
'butternut',
|
|
373
|
-
'green gem',
|
|
374
|
-
'red gem',
|
|
375
|
-
'starry night',
|
|
376
|
-
'benning',
|
|
377
|
-
'summar savor',
|
|
378
|
-
'summer savor',
|
|
379
|
-
'summery savor',
|
|
380
|
-
'summary savor',
|
|
381
|
-
'delicata',
|
|
382
|
-
'matador',
|
|
383
|
-
'green curl',
|
|
384
|
-
'red oak',
|
|
385
|
-
'flower',
|
|
386
|
-
'yellow tooth',
|
|
387
|
-
'sage\\b',
|
|
388
|
-
'sages\\b',
|
|
389
|
-
'okra',
|
|
390
|
-
'flor\\b',
|
|
391
|
-
'gems\\b',
|
|
392
|
-
'pump\\b',
|
|
393
|
-
'cruced\\b',
|
|
394
|
-
'star\\b',
|
|
395
|
-
'stars\\b',
|
|
396
|
-
'seed',
|
|
397
|
-
'pepper',
|
|
398
|
-
'chilli',
|
|
399
|
-
'mix\\b',
|
|
400
|
-
'chard',
|
|
401
|
-
'nettle',
|
|
402
|
-
'savory',
|
|
403
|
-
'dino',
|
|
404
|
-
|
|
405
|
-
// log activities
|
|
406
|
-
// NOTE: If i18n words change, these have to change too
|
|
407
|
-
'soil',
|
|
408
|
-
'irrigation',
|
|
409
|
-
'fertilization',
|
|
410
|
-
'crop protection',
|
|
411
|
-
'crop monitoring',
|
|
412
|
-
'direct seed',
|
|
413
|
-
'pruning',
|
|
414
|
-
'trellising',
|
|
415
|
-
'preparing crops',
|
|
416
|
-
'crops',
|
|
417
|
-
'estimating yield',
|
|
418
|
-
'other harvest',
|
|
419
|
-
'grading produce',
|
|
420
|
-
'moving produce',
|
|
421
|
-
'cold storage temperature',
|
|
422
|
-
'post harvest',
|
|
423
|
-
'sale',
|
|
424
|
-
'water testing',
|
|
425
|
-
'chlorine level',
|
|
426
|
-
'field',
|
|
427
|
-
];
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Get the icon name from crop name by using regex
|
|
431
|
-
* @param crop - The name of the crop
|
|
432
|
-
* @param note - Additional note that may contain crop type
|
|
433
|
-
* @param defaultIcon - The default icon to return if no match is found
|
|
434
|
-
* @returns The icon name or a default icon if no match is found
|
|
435
|
-
*/
|
|
436
|
-
|
|
437
|
-
export function getIconNameForArable(crop?: string | undefined, note?: string | null, defaultIcon?: string): string {
|
|
438
|
-
if (crop) {
|
|
439
|
-
const regex = new RegExp(`\\b(${PRODUCE_WORDS.join('|')})`, 'gi');
|
|
440
|
-
const match = crop.replace('-', ' ').match(regex);
|
|
441
|
-
if (match) {
|
|
442
|
-
let matchedWord;
|
|
443
|
-
if (match.length === 1) {
|
|
444
|
-
matchedWord = match[0].toLowerCase();
|
|
445
|
-
} else {
|
|
446
|
-
// If multiple matches, choose the first match from produce words
|
|
447
|
-
const lcMatch = match.map((m) => m.toLowerCase());
|
|
448
|
-
matchedWord = PRODUCE_WORDS.find((word) => lcMatch.includes(word));
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
switch (matchedWord) {
|
|
452
|
-
case 'little gem':
|
|
453
|
-
case 'lil gem':
|
|
454
|
-
case 'marciano':
|
|
455
|
-
case 'red butter':
|
|
456
|
-
case 'green gem':
|
|
457
|
-
case 'red gem':
|
|
458
|
-
case 'gems':
|
|
459
|
-
case 'spretnak':
|
|
460
|
-
case 'newham':
|
|
461
|
-
return 'vegetable-lettuce-top';
|
|
462
|
-
case 'lettuce':
|
|
463
|
-
case 'red oak':
|
|
464
|
-
case 'romaine':
|
|
465
|
-
case 'escarol':
|
|
466
|
-
case 'radicchio':
|
|
467
|
-
case 'braci ardenti':
|
|
468
|
-
case 'braci adenti':
|
|
469
|
-
case 'di lusia':
|
|
470
|
-
case 'di lusio':
|
|
471
|
-
case 'treviso':
|
|
472
|
-
case 'thaddeus':
|
|
473
|
-
case 'cruced':
|
|
474
|
-
return 'vegetable-lettuce';
|
|
475
|
-
case 'lavendar':
|
|
476
|
-
case 'lavender':
|
|
477
|
-
case 'anise hyssop':
|
|
478
|
-
case 'alyssum':
|
|
479
|
-
return 'vegetable-lavender';
|
|
480
|
-
case 'basil':
|
|
481
|
-
return 'vegetable-basil';
|
|
482
|
-
case 'chioggia':
|
|
483
|
-
case 'beet':
|
|
484
|
-
case 'yellow tooth':
|
|
485
|
-
return 'vegetable-beet';
|
|
486
|
-
case 'cauliflow':
|
|
487
|
-
case 'broccoli':
|
|
488
|
-
case 'piracicab':
|
|
489
|
-
return 'vegetable-broccoli';
|
|
490
|
-
case 'pumpkin':
|
|
491
|
-
case 'pump':
|
|
492
|
-
case 'cargo pump':
|
|
493
|
-
case 'bennings green':
|
|
494
|
-
case 'benning':
|
|
495
|
-
return 'vegetable-pumpkin';
|
|
496
|
-
case 'mesclun':
|
|
497
|
-
case 'spinach':
|
|
498
|
-
case 'chard':
|
|
499
|
-
case 'mustard green':
|
|
500
|
-
case 'mix':
|
|
501
|
-
return 'vegetable-spinach';
|
|
502
|
-
case 'tomato':
|
|
503
|
-
return 'vegetable-tomato';
|
|
504
|
-
case 'grapes':
|
|
505
|
-
return 'fruit-grapes';
|
|
506
|
-
case 'apricot':
|
|
507
|
-
case 'peach':
|
|
508
|
-
case 'plum':
|
|
509
|
-
return 'fruit-apricot';
|
|
510
|
-
case 'raspberr':
|
|
511
|
-
return 'raspberry';
|
|
512
|
-
case 'blackberr':
|
|
513
|
-
case 'cloudberr':
|
|
514
|
-
case 'cloud berr':
|
|
515
|
-
return 'fruit-cloud-berry';
|
|
516
|
-
case 'blueberr':
|
|
517
|
-
case 'billberr':
|
|
518
|
-
case 'berry':
|
|
519
|
-
return 'fruit-billberry-blackberry-blueberry';
|
|
520
|
-
case 'asparagus':
|
|
521
|
-
return 'vegetable-asparagus';
|
|
522
|
-
case 'sunshine kabocha':
|
|
523
|
-
case 'acorn squash':
|
|
524
|
-
case 'acornsquash':
|
|
525
|
-
case 'yellow star patty':
|
|
526
|
-
case 'sweet pepper':
|
|
527
|
-
case 'bell pepper':
|
|
528
|
-
return 'vegetable-acornsquash';
|
|
529
|
-
case 'strawberr':
|
|
530
|
-
return 'fruit-strawberry';
|
|
531
|
-
case 'pepper':
|
|
532
|
-
case 'chilli':
|
|
533
|
-
return 'seasoning-chilli';
|
|
534
|
-
case 'delicata':
|
|
535
|
-
case 'delicata squash':
|
|
536
|
-
return 'vegetable-delicata-squash';
|
|
537
|
-
case 'hubbard squash':
|
|
538
|
-
case 'hubbard':
|
|
539
|
-
case 'red kuri':
|
|
540
|
-
return 'vegetable-hubbard-squash';
|
|
541
|
-
case 'shinto':
|
|
542
|
-
case 'cucumber':
|
|
543
|
-
return 'vegetable-cucumber';
|
|
544
|
-
case 'butternut squash':
|
|
545
|
-
case 'butternutsquash':
|
|
546
|
-
case 'butternut':
|
|
547
|
-
case 'squash':
|
|
548
|
-
case 'starry night':
|
|
549
|
-
return 'vegetable-butternutsquash';
|
|
550
|
-
case 'summar savor':
|
|
551
|
-
case 'summer savor':
|
|
552
|
-
case 'summery savor':
|
|
553
|
-
case 'summary savor':
|
|
554
|
-
case 'thyme':
|
|
555
|
-
case 'rosemary':
|
|
556
|
-
case 'savory':
|
|
557
|
-
return 'vegetable-thyme';
|
|
558
|
-
case 'arugula':
|
|
559
|
-
case 'chicory':
|
|
560
|
-
case 'puntarelle':
|
|
561
|
-
case 'frisee':
|
|
562
|
-
case 'kale':
|
|
563
|
-
case 'dino':
|
|
564
|
-
case 'green curl':
|
|
565
|
-
return 'vegetable-arugula';
|
|
566
|
-
case 'parsley':
|
|
567
|
-
case 'beoc raab':
|
|
568
|
-
case 'wasabina':
|
|
569
|
-
case 'chervil':
|
|
570
|
-
return 'vegetable-parsley';
|
|
571
|
-
case 'carrot':
|
|
572
|
-
return 'vegetable-carrot';
|
|
573
|
-
case 'artichoke':
|
|
574
|
-
case 'romanesco':
|
|
575
|
-
case 'star':
|
|
576
|
-
case 'stars':
|
|
577
|
-
return 'vegetable-artichoke';
|
|
578
|
-
case 'cabbag':
|
|
579
|
-
return 'vegetable-cabbage';
|
|
580
|
-
case 'kohlrab':
|
|
581
|
-
return 'vegetable-kohlrabi';
|
|
582
|
-
case 'zucchini':
|
|
583
|
-
case 'zuchini':
|
|
584
|
-
case 'midnight light':
|
|
585
|
-
return 'vegetable-zucchini';
|
|
586
|
-
case 'potato':
|
|
587
|
-
return 'vegetable-potato';
|
|
588
|
-
case 'eggplant':
|
|
589
|
-
return 'vegetable-eggplant';
|
|
590
|
-
case 'jalapeno':
|
|
591
|
-
case 'jalapeño':
|
|
592
|
-
return 'vegetable-jalapeno';
|
|
593
|
-
case 'stinging kettle':
|
|
594
|
-
case 'nettle':
|
|
595
|
-
case 'cardoon':
|
|
596
|
-
case 'cynara cardunculus':
|
|
597
|
-
case 'cardunculus':
|
|
598
|
-
case 'cresta':
|
|
599
|
-
case 'shiso':
|
|
600
|
-
return 'vegetable-stinging-kettle';
|
|
601
|
-
case 'okra':
|
|
602
|
-
return 'vegetable-okra';
|
|
603
|
-
case 'sage':
|
|
604
|
-
case 'marjoram':
|
|
605
|
-
case 'sorrel':
|
|
606
|
-
case 'mint':
|
|
607
|
-
return 'plant-1';
|
|
608
|
-
case 'scallion':
|
|
609
|
-
case 'scalion':
|
|
610
|
-
case 'spring onion':
|
|
611
|
-
case 'springonion':
|
|
612
|
-
return 'vegetable-scallion';
|
|
613
|
-
case 'seed':
|
|
614
|
-
return 'gardening-seed-bag';
|
|
615
|
-
case 'onion':
|
|
616
|
-
case 'shallot':
|
|
617
|
-
case 'matador':
|
|
618
|
-
return 'vegetable-onion';
|
|
619
|
-
case 'bean':
|
|
620
|
-
case 'stringbean':
|
|
621
|
-
return 'vegetable-stringbean-1';
|
|
622
|
-
case 'cilantro':
|
|
623
|
-
case 'flor':
|
|
624
|
-
return 'vegetable-cilantro';
|
|
625
|
-
case 'raddish':
|
|
626
|
-
case 'radish':
|
|
627
|
-
return 'vegetable-radish';
|
|
628
|
-
case 'wasabi':
|
|
629
|
-
return 'vegetable-wasabi';
|
|
630
|
-
case 'flower':
|
|
631
|
-
return 'flower';
|
|
632
|
-
case 'soil':
|
|
633
|
-
return 'product-growth-tree-box';
|
|
634
|
-
case 'irrigation':
|
|
635
|
-
return 'gardening-sprinkler';
|
|
636
|
-
case 'direct seed':
|
|
637
|
-
return 'agriculture-machine-seeder';
|
|
638
|
-
case 'fertilization':
|
|
639
|
-
return 'organic-bag-leaf';
|
|
640
|
-
case 'crop protection':
|
|
641
|
-
return 'gardening-tools-1';
|
|
642
|
-
case 'crop monitoring':
|
|
643
|
-
case 'field':
|
|
644
|
-
return 'farming-barn-sun';
|
|
645
|
-
case 'pruning':
|
|
646
|
-
return 'gardening-scissors';
|
|
647
|
-
case 'trellising':
|
|
648
|
-
return 'barbed-wire-fence';
|
|
649
|
-
case 'preparing crops':
|
|
650
|
-
return 'protein-gluten-wheat';
|
|
651
|
-
case 'crops':
|
|
652
|
-
return 'harvest-product';
|
|
653
|
-
case 'estimating yield':
|
|
654
|
-
case 'other harvest':
|
|
655
|
-
return 'crop-info-biotech-1';
|
|
656
|
-
case 'grading produce':
|
|
657
|
-
case 'moving produce':
|
|
658
|
-
return 'harvest-product';
|
|
659
|
-
case 'post harvest':
|
|
660
|
-
return 'warehouse-storage';
|
|
661
|
-
case 'cold storage temperature':
|
|
662
|
-
return 'temperature-control-warehouse-1';
|
|
663
|
-
case 'sale':
|
|
664
|
-
return 'receipt-dollar';
|
|
665
|
-
case 'water testing':
|
|
666
|
-
case 'chlorine level':
|
|
667
|
-
return 'organic-flask';
|
|
668
|
-
default:
|
|
669
|
-
console.log('Missing switchcase for crop:', crop);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// console.log('No match found for crop:', crop);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
if (note) {
|
|
677
|
-
return getIconNameForArable(note, null, defaultIcon);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
return defaultIcon || 'seedling';
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* Get the icon name for livestock using regex
|
|
685
|
-
* @param purchasedItem - The name of the purchased item
|
|
686
|
-
* @param note - Additional note that may contain livestock type
|
|
687
|
-
* @param defaultIcon - The default icon to return if no match is found
|
|
688
|
-
* @returns The icon name or a default icon if no match is found
|
|
689
|
-
*/
|
|
690
|
-
|
|
691
|
-
export function getIconNameForLivestock(
|
|
692
|
-
purchasedItem?: string | null,
|
|
693
|
-
note?: string | null,
|
|
694
|
-
defaultIcon?: string,
|
|
695
|
-
): string {
|
|
696
|
-
if (purchasedItem) {
|
|
697
|
-
// return 'seedling';
|
|
698
|
-
const LIVESTOCK_WORDS = [
|
|
699
|
-
'hay\\b',
|
|
700
|
-
'cow',
|
|
701
|
-
'calf',
|
|
702
|
-
'cattle',
|
|
703
|
-
'bull',
|
|
704
|
-
'sheep',
|
|
705
|
-
];
|
|
706
|
-
|
|
707
|
-
const regex = new RegExp(`\\b(${LIVESTOCK_WORDS.join('|')})`, 'gi');
|
|
708
|
-
const match = purchasedItem.replace('-', ' ').match(regex);
|
|
709
|
-
if (match) {
|
|
710
|
-
let matchedWord;
|
|
711
|
-
if (match.length === 1) {
|
|
712
|
-
matchedWord = match[0].toLowerCase();
|
|
713
|
-
} else {
|
|
714
|
-
// If multiple matches, choose the first match from produce words
|
|
715
|
-
const lcMatch = match.map((m) => m.toLowerCase());
|
|
716
|
-
matchedWord = LIVESTOCK_WORDS.find((word) => lcMatch.includes(word));
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
switch (matchedWord) {
|
|
720
|
-
case 'hay':
|
|
721
|
-
return 'farming-hay';
|
|
722
|
-
case 'cow':
|
|
723
|
-
case 'calf':
|
|
724
|
-
case 'cattle':
|
|
725
|
-
case 'bull':
|
|
726
|
-
return 'livestock-cow-body';
|
|
727
|
-
default:
|
|
728
|
-
console.log('Missing switchcase for crop:', purchasedItem);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
console.log('No match found for crop:', purchasedItem);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
if (note) {
|
|
736
|
-
return getIconNameForLivestock(note, null, defaultIcon);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
return defaultIcon || 'oat-2';
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* Get the icon name for farmers market using regex
|
|
744
|
-
* @param purchasedItem - The name of the purchased item
|
|
745
|
-
* @param note - Additional note that may contain livestock type
|
|
746
|
-
* @param defaultIcon - The default icon to return if no match is found
|
|
747
|
-
* @returns The icon name or a default icon if no match is found
|
|
748
|
-
*/
|
|
749
|
-
|
|
750
|
-
export function getIconNameForFarmersMarket(
|
|
751
|
-
purchasedItem?: string | null,
|
|
752
|
-
note?: string | null,
|
|
753
|
-
defaultIcon?: string,
|
|
754
|
-
): string {
|
|
755
|
-
if (purchasedItem) {
|
|
756
|
-
// return 'seedling';
|
|
757
|
-
const FARMERS_MARKET_WORDS = [
|
|
758
|
-
'hay\\b',
|
|
759
|
-
'cow',
|
|
760
|
-
'calf',
|
|
761
|
-
'cattle',
|
|
762
|
-
'bull',
|
|
763
|
-
'sheep',
|
|
764
|
-
];
|
|
765
|
-
|
|
766
|
-
const regex = new RegExp(`\\b(${FARMERS_MARKET_WORDS.join('|')})`, 'gi');
|
|
767
|
-
const match = purchasedItem.replace('-', ' ').match(regex);
|
|
768
|
-
if (match) {
|
|
769
|
-
let matchedWord;
|
|
770
|
-
if (match.length === 1) {
|
|
771
|
-
matchedWord = match[0].toLowerCase();
|
|
772
|
-
} else {
|
|
773
|
-
// If multiple matches, choose the first match from produce words
|
|
774
|
-
const lcMatch = match.map((m) => m.toLowerCase());
|
|
775
|
-
matchedWord = FARMERS_MARKET_WORDS.find((word) => lcMatch.includes(word));
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
switch (matchedWord) {
|
|
779
|
-
case 'hay':
|
|
780
|
-
return 'farming-hay';
|
|
781
|
-
case 'cow':
|
|
782
|
-
case 'calf':
|
|
783
|
-
case 'cattle':
|
|
784
|
-
case 'bull':
|
|
785
|
-
return 'livestock-cow-body';
|
|
786
|
-
default:
|
|
787
|
-
console.log('Missing switchcase for crop:', purchasedItem);
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
// console.log('No match found for farmers market:', purchasedItem);
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
if (note) {
|
|
795
|
-
return getIconNameForFarmersMarket(note, null, defaultIcon);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
return defaultIcon || 'farmers-market-kiosk';
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Get any icon name for any word
|
|
803
|
-
*/
|
|
804
|
-
|
|
805
|
-
export function getIconNameForWord(
|
|
806
|
-
decidingWord: any,
|
|
807
|
-
text1: string,
|
|
808
|
-
text2?: string | null,
|
|
809
|
-
defaultIcon?: string,
|
|
810
|
-
) {
|
|
811
|
-
switch (decidingWord) {
|
|
812
|
-
case 'ARABLE':
|
|
813
|
-
case 'LogArable':
|
|
814
|
-
return getIconNameForArable(text1, text2, defaultIcon);
|
|
815
|
-
case 'LIVESTOCK':
|
|
816
|
-
case 'LogLivestock':
|
|
817
|
-
return getIconNameForLivestock(text1, text2, defaultIcon);
|
|
818
|
-
case 'FARMERS_MARKET':
|
|
819
|
-
case 'LogFarmersMarket':
|
|
820
|
-
return getIconNameForFarmersMarket(text1, text2, defaultIcon);
|
|
821
|
-
default:
|
|
822
|
-
// titleIconName = COMMON_ICON_NAMES.document;
|
|
823
|
-
}
|
|
824
|
-
return 'circle';
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* Get icon name for any operation using regex
|
|
829
|
-
* @param details - GraphQL log details object
|
|
830
|
-
* @param defaultIcon - The default icon to return if no match is found
|
|
831
|
-
* @returns The icon name or a default icon if no match is found
|
|
832
|
-
*/
|
|
833
|
-
|
|
834
|
-
export function getIconNameForLog(
|
|
835
|
-
details: any,
|
|
836
|
-
preferActivityText?: boolean,
|
|
837
|
-
defaultIcon_?: string,
|
|
838
|
-
) {
|
|
839
|
-
// "crop" is deprecation support -- it should be "item" going forward
|
|
840
|
-
const text1 = preferActivityText ? details.activity : details.item;
|
|
841
|
-
const text2 = preferActivityText ? (details.title + ' ' + details.notes) : details.notes;
|
|
842
|
-
// @ts-ignore - allow dynamic key access
|
|
843
|
-
const defaultIcon = (preferActivityText && COMMON_ICON_NAMES[details.activity]) || defaultIcon_;
|
|
844
|
-
|
|
845
|
-
// console.log('defaultIcon', preferActivityText, details.activity, defaultIcon);
|
|
846
|
-
|
|
847
|
-
return getIconNameForWord(details.__typename, text1, text2, defaultIcon);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* Get title for log
|
|
852
|
-
*/
|
|
853
|
-
|
|
854
|
-
export function getTitleForLog(details: any): string {
|
|
855
|
-
switch (details.__typename) {
|
|
856
|
-
case 'LogFarmersMarket':
|
|
857
|
-
{
|
|
858
|
-
// Check if text from values is short, else rely on the AI summary
|
|
859
|
-
const valuesText = (details.values || []).map((item: any) => {
|
|
860
|
-
return `${item.label} ${item.value ? formatCurrency(item.value, false) : ''}`.trim();
|
|
861
|
-
}).join(', ');
|
|
862
|
-
|
|
863
|
-
if (valuesText.length <= 40) {
|
|
864
|
-
return valuesText;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
break;
|
|
868
|
-
default:
|
|
869
|
-
}
|
|
870
|
-
return details.item;
|
|
871
|
-
}
|