@jsb188/mday-web 1.1.10 → 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.
- package/package.json +34 -24
- package/src/libs/route-metadata.server.ts +67 -0
- package/src/modules/AgentDocs.tsx +800 -0
- package/src/modules/DocAccessSettings.tsx +963 -0
- package/src/modules/Grids.tsx +842 -0
- package/src/modules/RouteShell.tsx +76 -0
- package/src/utils/account-web.ts +64 -0
- package/src/utils/list-web.ts +17 -0
- package/src/utils/log-web.ts +162 -52
- package/src/utils/org-web.ts +35 -8
- package/src/utils/route-helpers.ts +902 -596
- package/src/utils/workflow-web.ts +96 -0
- package/tsconfig.json +11 -11
- package/src/modules/DataTable-ContextMenu.tsx +0 -169
- package/src/modules/DataTable-InboundContact.tsx +0 -523
- package/src/modules/DataTable.tsx +0 -5060
- package/src/modules/Sheet-ContextMenu.tsx +0 -161
- package/src/modules/Sheet.tsx +0 -28
- package/src/modules/cell-save-beacon.ts +0 -67
- package/src/modules/dataTable-interaction-state.ts +0 -276
- package/src/modules/dataTable-shortcuts.ts +0 -192
- package/src/modules/dataTable-viewport.ts +0 -89
- package/src/modules/grid-cell-render.ts +0 -72
- package/src/modules/grid-context-menu.ts +0 -112
- package/src/modules/grid-keyboard.ts +0 -267
- package/src/modules/grid-render-store.ts +0 -103
- package/src/modules/grid-runtime.ts +0 -178
- package/src/modules/grid-selection.ts +0 -336
- package/src/modules/grid-viewport.ts +0 -57
- package/src/modules/use-dataTable-states.ts +0 -529
- package/src/modules/use-debounced-cell-save-batch.ts +0 -160
- package/tests/DataTable.test.tsx +0 -4466
- package/tests/dataTable-interaction-state.test.ts +0 -127
|
@@ -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,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
|
+
}
|
package/src/utils/log-web.ts
CHANGED
|
@@ -2,30 +2,111 @@ import { formatCurrency } from '@jsb188/app/utils/number.ts';
|
|
|
2
2
|
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
3
3
|
|
|
4
4
|
const ARABLE_ICON_WORD_GROUPS: [string, string[]][] = [
|
|
5
|
-
[
|
|
6
|
-
|
|
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
|
+
],
|
|
7
38
|
['vegetable-lavender', ['lavendar', 'lavender', 'anise hyssop', 'alyssum']],
|
|
8
39
|
['vegetable-basil', ['basil']],
|
|
9
40
|
['vegetable-beet', ['chioggia', 'beet', 'yellow tooth']],
|
|
10
41
|
['vegetable-broccoli', ['cauliflow', 'broccoli', 'piracicab']],
|
|
11
|
-
[
|
|
12
|
-
|
|
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
|
+
],
|
|
13
50
|
['vegetable-tomato', ['tomato']],
|
|
14
51
|
['fruit-grapes', ['grapes']],
|
|
15
52
|
['fruit-apricot', ['apricot', 'peach', 'plum']],
|
|
16
53
|
['raspberry', ['raspberr']],
|
|
17
54
|
['fruit-cloud-berry', ['blackberr', 'cloudberr', 'cloud berr']],
|
|
18
|
-
[
|
|
55
|
+
[
|
|
56
|
+
'fruit-billberry-blackberry-blueberry',
|
|
57
|
+
['blueberr', 'billberr', 'berry', '\\w*berr(?:y|ies)\\b'],
|
|
58
|
+
],
|
|
19
59
|
['vegetable-asparagus', ['asparagus']],
|
|
20
|
-
[
|
|
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
|
+
],
|
|
21
71
|
['fruit-strawberry', ['strawberr']], // commented now for testing
|
|
22
72
|
['seasoning-chilli', ['pepper', 'chilli']],
|
|
23
73
|
['vegetable-delicata-squash', ['delicata', 'delicata squash']],
|
|
24
74
|
['vegetable-hubbard-squash', ['hubbard squash', 'hubbard', 'red kuri']],
|
|
25
75
|
['vegetable-cucumber', ['shinto', 'cucumber', 'pickle']],
|
|
26
|
-
[
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
],
|
|
29
110
|
['vegetable-parsley', ['parsley', 'beoc raab', 'wasabina', 'chervil']],
|
|
30
111
|
['vegetable-carrot', ['carrot']],
|
|
31
112
|
['vegetable-artichoke', ['artichoke', 'romanesco', 'star\\b', 'stars\\b']],
|
|
@@ -35,10 +116,24 @@ const ARABLE_ICON_WORD_GROUPS: [string, string[]][] = [
|
|
|
35
116
|
['vegetable-potato', ['potato']],
|
|
36
117
|
['vegetable-eggplant', ['eggplant']],
|
|
37
118
|
['vegetable-jalapeno', ['jalapeno', 'jalapeño']],
|
|
38
|
-
[
|
|
119
|
+
[
|
|
120
|
+
'vegetable-stinging-kettle',
|
|
121
|
+
[
|
|
122
|
+
'stinging kettle',
|
|
123
|
+
'nettle',
|
|
124
|
+
'cardoon',
|
|
125
|
+
'cynara cardunculus',
|
|
126
|
+
'cardunculus',
|
|
127
|
+
'cresta',
|
|
128
|
+
'shiso',
|
|
129
|
+
],
|
|
130
|
+
],
|
|
39
131
|
['vegetable-okra', ['okra']],
|
|
40
132
|
['plant-1', ['sage\\b', 'sages\\b', 'marjoram', 'sorrel', 'mint']],
|
|
41
|
-
[
|
|
133
|
+
[
|
|
134
|
+
'vegetable-scallion',
|
|
135
|
+
['scallion', 'scalion', 'spring onion', 'springonion'],
|
|
136
|
+
],
|
|
42
137
|
['gardening-seed-bag', ['seed']],
|
|
43
138
|
['vegetable-onion', ['onion', 'shallot', 'matador']],
|
|
44
139
|
['vegetable-black-bean', ['oliv']],
|
|
@@ -234,10 +329,17 @@ const ARABLE_ICON_PRIORITY_WORDS = [
|
|
|
234
329
|
'field',
|
|
235
330
|
];
|
|
236
331
|
const ARABLE_ICON_BY_WORD = new Map(
|
|
237
|
-
ARABLE_ICON_WORD_GROUPS.flatMap(([iconName, words]) =>
|
|
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,
|
|
238
342
|
);
|
|
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
343
|
|
|
242
344
|
/*
|
|
243
345
|
* Normalize a matched icon word so regex-only word boundary markers do not affect map lookups.
|
|
@@ -251,14 +353,20 @@ function normalizeIconMatchWord(word: string): string {
|
|
|
251
353
|
*/
|
|
252
354
|
function getPreferredArableIconWord(matches: string[]): string {
|
|
253
355
|
if (matches.length === 1) {
|
|
254
|
-
const matchedPriorityWord = ARABLE_ICON_PRIORITY_MATCHERS.find(
|
|
356
|
+
const matchedPriorityWord = ARABLE_ICON_PRIORITY_MATCHERS.find(
|
|
357
|
+
([, regex]) => regex.test(matches[0]),
|
|
358
|
+
)?.[0];
|
|
255
359
|
|
|
256
360
|
return normalizeIconMatchWord(matchedPriorityWord || matches[0]);
|
|
257
361
|
}
|
|
258
362
|
|
|
259
|
-
const preferredWord = ARABLE_ICON_PRIORITY_MATCHERS.find(([, regex]) =>
|
|
363
|
+
const preferredWord = ARABLE_ICON_PRIORITY_MATCHERS.find(([, regex]) =>
|
|
364
|
+
matches.some((match) => regex.test(match)),
|
|
365
|
+
)?.[0];
|
|
260
366
|
|
|
261
|
-
return preferredWord
|
|
367
|
+
return preferredWord
|
|
368
|
+
? normalizeIconMatchWord(preferredWord)
|
|
369
|
+
: normalizeIconMatchWord(matches[0]);
|
|
262
370
|
}
|
|
263
371
|
|
|
264
372
|
/**
|
|
@@ -269,7 +377,11 @@ function getPreferredArableIconWord(matches: string[]): string {
|
|
|
269
377
|
* @returns The icon name or a default icon if no match is found
|
|
270
378
|
*/
|
|
271
379
|
|
|
272
|
-
export function getIconNameForArable(
|
|
380
|
+
export function getIconNameForArable(
|
|
381
|
+
crop?: string | undefined,
|
|
382
|
+
note?: string | null,
|
|
383
|
+
defaultIcon?: string,
|
|
384
|
+
): string {
|
|
273
385
|
if (crop) {
|
|
274
386
|
const match = crop.replace(/-/g, ' ').match(ARABLE_WORD_REGEX);
|
|
275
387
|
if (match) {
|
|
@@ -296,7 +408,7 @@ export function getIconNameForArable(crop?: string | undefined, note?: string |
|
|
|
296
408
|
/**
|
|
297
409
|
* Get the icon name for farmers market using regex
|
|
298
410
|
* @param purchasedItem - The name of the purchased item
|
|
299
|
-
* @param note - Additional note that may contain
|
|
411
|
+
* @param note - Additional note that may contain a market item type
|
|
300
412
|
* @param defaultIcon - The default icon to return if no match is found
|
|
301
413
|
* @returns The icon name or a default icon if no match is found
|
|
302
414
|
*/
|
|
@@ -308,35 +420,25 @@ export function getIconNameForFarmersMarket(
|
|
|
308
420
|
): string {
|
|
309
421
|
if (purchasedItem) {
|
|
310
422
|
// return 'seedling';
|
|
311
|
-
const FARMERS_MARKET_WORDS = [
|
|
312
|
-
'hay\\b',
|
|
313
|
-
'cow',
|
|
314
|
-
'calf',
|
|
315
|
-
'cattle',
|
|
316
|
-
'bull',
|
|
317
|
-
'sheep',
|
|
318
|
-
];
|
|
423
|
+
const FARMERS_MARKET_WORDS = ['hay\\b'];
|
|
319
424
|
|
|
320
425
|
const regex = new RegExp(`\\b(${FARMERS_MARKET_WORDS.join('|')})`, 'gi');
|
|
321
426
|
const match = purchasedItem.replace('-', ' ').match(regex);
|
|
322
427
|
if (match) {
|
|
323
|
-
let matchedWord;
|
|
428
|
+
let matchedWord: string | undefined;
|
|
324
429
|
if (match.length === 1) {
|
|
325
430
|
matchedWord = match[0].toLowerCase();
|
|
326
431
|
} else {
|
|
327
432
|
// If multiple matches, choose the first match from produce words
|
|
328
433
|
const lcMatch = match.map((m) => m.toLowerCase());
|
|
329
|
-
matchedWord = FARMERS_MARKET_WORDS.find((word) =>
|
|
434
|
+
matchedWord = FARMERS_MARKET_WORDS.find((word) =>
|
|
435
|
+
lcMatch.includes(word),
|
|
436
|
+
);
|
|
330
437
|
}
|
|
331
438
|
|
|
332
439
|
switch (matchedWord) {
|
|
333
440
|
case 'hay':
|
|
334
441
|
return 'farming-hay';
|
|
335
|
-
case 'cow':
|
|
336
|
-
case 'calf':
|
|
337
|
-
case 'cattle':
|
|
338
|
-
case 'bull':
|
|
339
|
-
return 'livestock-cow-body';
|
|
340
442
|
default:
|
|
341
443
|
console.log('Missing switchcase for crop:', purchasedItem);
|
|
342
444
|
}
|
|
@@ -373,20 +475,17 @@ export function getIconNameForGrowerNetwork(
|
|
|
373
475
|
*/
|
|
374
476
|
|
|
375
477
|
export function getIconNameForWord(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
478
|
+
decidingWord: any,
|
|
479
|
+
text1: string,
|
|
480
|
+
text2?: string | null,
|
|
481
|
+
defaultIcon?: string,
|
|
380
482
|
) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
case 'LogArable':
|
|
483
|
+
switch (decidingWord) {
|
|
484
|
+
case 'ARABLE':
|
|
384
485
|
return getIconNameForArable(text1, text2, defaultIcon);
|
|
385
|
-
|
|
386
|
-
case 'LogFarmersMarket':
|
|
486
|
+
case 'FARMERS_MARKET':
|
|
387
487
|
return getIconNameForFarmersMarket(text1, text2, defaultIcon);
|
|
388
488
|
case 'GROWER_NETWORK':
|
|
389
|
-
case 'LogGrowerNetwork':
|
|
390
489
|
return getIconNameForGrowerNetwork(text1, text2, defaultIcon);
|
|
391
490
|
default:
|
|
392
491
|
}
|
|
@@ -407,13 +506,22 @@ export function getIconNameForLog(
|
|
|
407
506
|
) {
|
|
408
507
|
// "crop" is deprecation support -- it should be "item" going forward
|
|
409
508
|
const text1 = preferActivityText ? details.activity : details.item;
|
|
410
|
-
const text2 = preferActivityText
|
|
509
|
+
const text2 = preferActivityText
|
|
510
|
+
? details.title + ' ' + details.notes
|
|
511
|
+
: details.notes;
|
|
411
512
|
// @ts-ignore - allow dynamic key access
|
|
412
|
-
const defaultIcon =
|
|
513
|
+
const defaultIcon =
|
|
514
|
+
(preferActivityText && COMMON_ICON_NAMES[details.activity]) || defaultIcon_;
|
|
413
515
|
|
|
414
516
|
// console.log('defaultIcon', preferActivityText, details.activity, defaultIcon);
|
|
415
517
|
|
|
416
|
-
|
|
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);
|
|
417
525
|
}
|
|
418
526
|
|
|
419
527
|
/**
|
|
@@ -421,13 +529,15 @@ export function getIconNameForLog(
|
|
|
421
529
|
*/
|
|
422
530
|
|
|
423
531
|
export function getTitleForLog(details: any): string {
|
|
424
|
-
switch (details.
|
|
425
|
-
case '
|
|
532
|
+
switch (details.type) {
|
|
533
|
+
case 'MARKET_RECEIPT':
|
|
426
534
|
{
|
|
427
535
|
// Check if text from values is short, else rely on the AI summary
|
|
428
|
-
const valuesText = (details.values || [])
|
|
429
|
-
|
|
430
|
-
|
|
536
|
+
const valuesText = (details.values || [])
|
|
537
|
+
.map((item: any) => {
|
|
538
|
+
return `${item.label} ${item.value ? formatCurrency(item.value, false) : ''}`.trim();
|
|
539
|
+
})
|
|
540
|
+
.join(', ');
|
|
431
541
|
|
|
432
542
|
if (valuesText.length <= 40) {
|
|
433
543
|
return valuesText;
|
package/src/utils/org-web.ts
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
OrganizationGQL,
|
|
4
|
+
OrganizationOperationEnum,
|
|
5
|
+
} from '@jsb188/mday/types/organization.d.ts';
|
|
3
6
|
import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
* Get
|
|
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
|
|
8
|
+
/*
|
|
9
|
+
* Get the icon name for one organization operation.
|
|
10
10
|
*/
|
|
11
|
+
export function getOrgOperationIconName(
|
|
12
|
+
operation?: OrganizationOperationEnum | string | null,
|
|
13
|
+
): string {
|
|
14
|
+
return (operation && COMMON_ICON_NAMES[operation]) || COMMON_ICON_NAMES.info;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Get the <SimpleLabel> preset for one organization role badge. Owners and
|
|
19
|
+
* admins get colored outlines; every other role falls back to a neutral outline.
|
|
20
|
+
*/
|
|
21
|
+
export function getOrgRoleLabelPreset(
|
|
22
|
+
role?: string | null,
|
|
23
|
+
): 'outline_main' | 'outline_primary' | 'outline_secondary' | 'outline' {
|
|
24
|
+
switch (role) {
|
|
25
|
+
case 'OWNER':
|
|
26
|
+
return 'outline_primary';
|
|
27
|
+
case 'ADMIN':
|
|
28
|
+
return 'outline_secondary';
|
|
29
|
+
default:
|
|
30
|
+
return 'outline';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
11
33
|
|
|
34
|
+
/*
|
|
35
|
+
* Get all title icons for organization/vendor.
|
|
36
|
+
*/
|
|
12
37
|
export function getTitleIconsForOrganization(
|
|
13
38
|
org: OrganizationGQL,
|
|
14
39
|
showIconsRule: Record<string, boolean> = {},
|
|
@@ -18,7 +43,7 @@ export function getTitleIconsForOrganization(
|
|
|
18
43
|
|
|
19
44
|
if (operation && showIconsRule.operation !== false) {
|
|
20
45
|
titleIcons.push({
|
|
21
|
-
iconName:
|
|
46
|
+
iconName: getOrgOperationIconName(operation),
|
|
22
47
|
tooltipText: i18n.t(`org.type.${operation}`),
|
|
23
48
|
});
|
|
24
49
|
}
|
|
@@ -26,7 +51,9 @@ export function getTitleIconsForOrganization(
|
|
|
26
51
|
if (compliance?.length && showIconsRule.compliance !== false) {
|
|
27
52
|
const today = new Date();
|
|
28
53
|
const todayCalDate = today.toISOString().split('T')[0];
|
|
29
|
-
const notExpired = compliance.filter(
|
|
54
|
+
const notExpired = compliance.filter(
|
|
55
|
+
(item: any) => item.expirationDate && item.expirationDate > todayCalDate,
|
|
56
|
+
);
|
|
30
57
|
|
|
31
58
|
if (notExpired.length > 0) {
|
|
32
59
|
titleIcons.push({
|