@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.
Files changed (33) hide show
  1. package/package.json +34 -24
  2. package/src/libs/route-metadata.server.ts +67 -0
  3. package/src/modules/AgentDocs.tsx +800 -0
  4. package/src/modules/DocAccessSettings.tsx +963 -0
  5. package/src/modules/Grids.tsx +842 -0
  6. package/src/modules/RouteShell.tsx +76 -0
  7. package/src/utils/account-web.ts +64 -0
  8. package/src/utils/list-web.ts +17 -0
  9. package/src/utils/log-web.ts +162 -52
  10. package/src/utils/org-web.ts +35 -8
  11. package/src/utils/route-helpers.ts +902 -596
  12. package/src/utils/workflow-web.ts +96 -0
  13. package/tsconfig.json +11 -11
  14. package/src/modules/DataTable-ContextMenu.tsx +0 -169
  15. package/src/modules/DataTable-InboundContact.tsx +0 -523
  16. package/src/modules/DataTable.tsx +0 -5060
  17. package/src/modules/Sheet-ContextMenu.tsx +0 -161
  18. package/src/modules/Sheet.tsx +0 -28
  19. package/src/modules/cell-save-beacon.ts +0 -67
  20. package/src/modules/dataTable-interaction-state.ts +0 -276
  21. package/src/modules/dataTable-shortcuts.ts +0 -192
  22. package/src/modules/dataTable-viewport.ts +0 -89
  23. package/src/modules/grid-cell-render.ts +0 -72
  24. package/src/modules/grid-context-menu.ts +0 -112
  25. package/src/modules/grid-keyboard.ts +0 -267
  26. package/src/modules/grid-render-store.ts +0 -103
  27. package/src/modules/grid-runtime.ts +0 -178
  28. package/src/modules/grid-selection.ts +0 -336
  29. package/src/modules/grid-viewport.ts +0 -57
  30. package/src/modules/use-dataTable-states.ts +0 -529
  31. package/src/modules/use-debounced-cell-save-batch.ts +0 -160
  32. package/tests/DataTable.test.tsx +0 -4466
  33. 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
+ }
@@ -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
- ['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']],
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
- ['vegetable-pumpkin', ['pumpkin', 'pump\\b', 'cargo pump', 'bennings green', 'benning']],
12
- ['vegetable-spinach', ['mesclun', 'spinach', 'chard', 'mustard green', 'mix\\b']],
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
- ['fruit-billberry-blackberry-blueberry', ['blueberr', 'billberr', 'berry', '\\w*berr(?:y|ies)\\b']],
55
+ [
56
+ 'fruit-billberry-blackberry-blueberry',
57
+ ['blueberr', 'billberr', 'berry', '\\w*berr(?:y|ies)\\b'],
58
+ ],
19
59
  ['vegetable-asparagus', ['asparagus']],
20
- ['vegetable-acornsquash', ['sunshine kabocha', 'acorn squash', 'acornsquash', 'yellow star patty', 'sweet pepper', 'bell pepper']],
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
- ['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']],
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
- ['vegetable-stinging-kettle', ['stinging kettle', 'nettle', 'cardoon', 'cynara cardunculus', 'cardunculus', 'cresta', 'shiso']],
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
- ['vegetable-scallion', ['scallion', 'scalion', 'spring onion', 'springonion']],
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]) => words.map((word) => [normalizeIconMatchWord(word), iconName])),
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(([, regex]) => regex.test(matches[0]))?.[0];
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]) => matches.some((match) => regex.test(match)))?.[0];
363
+ const preferredWord = ARABLE_ICON_PRIORITY_MATCHERS.find(([, regex]) =>
364
+ matches.some((match) => regex.test(match)),
365
+ )?.[0];
260
366
 
261
- return preferredWord ? normalizeIconMatchWord(preferredWord) : normalizeIconMatchWord(matches[0]);
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(crop?: string | undefined, note?: string | null, defaultIcon?: string): string {
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 livestock type
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) => lcMatch.includes(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
- decidingWord: any,
377
- text1: string,
378
- text2?: string | null,
379
- defaultIcon?: string,
478
+ decidingWord: any,
479
+ text1: string,
480
+ text2?: string | null,
481
+ defaultIcon?: string,
380
482
  ) {
381
- switch (decidingWord) {
382
- case 'ARABLE':
383
- case 'LogArable':
483
+ switch (decidingWord) {
484
+ case 'ARABLE':
384
485
  return getIconNameForArable(text1, text2, defaultIcon);
385
- case 'FARMERS_MARKET':
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 ? (details.title + ' ' + details.notes) : details.notes;
509
+ const text2 = preferActivityText
510
+ ? details.title + ' ' + details.notes
511
+ : details.notes;
411
512
  // @ts-ignore - allow dynamic key access
412
- const defaultIcon = (preferActivityText && COMMON_ICON_NAMES[details.activity]) || 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
- return getIconNameForWord(details.__typename, text1, text2, defaultIcon);
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.__typename) {
425
- case 'LogFarmersMarket':
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 || []).map((item: any) => {
429
- return `${item.label} ${item.value ? formatCurrency(item.value, false) : ''}`.trim();
430
- }).join(', ');
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;
@@ -1,14 +1,39 @@
1
1
  import i18n from '@jsb188/app/i18n/index.ts';
2
- import type { OrganizationGQL } from '@jsb188/mday/types/organization.d.ts';
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 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
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: COMMON_ICON_NAMES[operation] || 'info-circle',
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((item: any) => item.expirationDate && item.expirationDate > todayCalDate);
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({