@cccsaurora/howler-ui 2.17.0-dev.513 → 2.17.0-dev.514

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.
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Article, BookRounded, ChevronRight, Folder as FolderIcon } from '@mui/icons-material';
2
+ import { Article, BookRounded, CheckCircle, ChevronRight, Folder as FolderIcon, Lightbulb, Link as LinkIcon, TableChart, Visibility } from '@mui/icons-material';
3
3
  import { Skeleton, Stack, Typography, useTheme } from '@mui/material';
4
4
  import api from '@cccsaurora/howler-ui/api';
5
5
  import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
6
6
  import { get, last, omit, set } from 'lodash-es';
7
- import { useMemo, useState } from 'react';
7
+ import { useEffect, useMemo, useState } from 'react';
8
8
  import { Link, useLocation } from 'react-router-dom';
9
+ import { ESCALATION_COLORS, STATUS_COLORS } from '@cccsaurora/howler-ui/utils/constants';
9
10
  const buildTree = (items = []) => {
10
11
  // Root tree node stores direct children in `leaves` and nested folders as object keys.
11
12
  const tree = { leaves: [] };
@@ -38,8 +39,43 @@ const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPref
38
39
  const [openCases, setOpenCases] = useState({});
39
40
  const [loadingCases, setLoadingCases] = useState({});
40
41
  const [nestedCases, setNestedCases] = useState({});
42
+ const [hitMetadata, setHitMetadata] = useState({});
41
43
  const tree = useMemo(() => folder || buildTree(_case?.items), [folder, _case?.items]);
42
44
  const currentRootCaseId = rootCaseId || _case?.case_id;
45
+ // Metadata for hit-type items
46
+ useEffect(() => {
47
+ tree.leaves
48
+ ?.filter(leaf => leaf.type?.toLowerCase() === 'hit')
49
+ .forEach(leaf => {
50
+ dispatchApi(api.hit.get(leaf.id), { throwError: false }).then(hit => {
51
+ if (!hit)
52
+ return;
53
+ setHitMetadata(prev => ({
54
+ ...prev,
55
+ [leaf.id]: {
56
+ status: hit.howler?.status,
57
+ escalation: hit.howler?.escalation,
58
+ assessment: hit.howler?.assessment
59
+ }
60
+ }));
61
+ });
62
+ });
63
+ }, [tree.leaves, dispatchApi]);
64
+ const getItemColor = (itemType, itemKey, leafId) => {
65
+ if (itemType === 'hit' && leafId) {
66
+ const meta = hitMetadata[leafId];
67
+ if (meta?.status && STATUS_COLORS[meta.status]) {
68
+ return `${STATUS_COLORS[meta.status]}.main`;
69
+ }
70
+ }
71
+ if (itemType === 'case' && itemKey) {
72
+ const caseData = nestedCases[itemKey];
73
+ if (caseData?.escalation && ESCALATION_COLORS[caseData.escalation]) {
74
+ return `${ESCALATION_COLORS[caseData.escalation]}.main`;
75
+ }
76
+ }
77
+ return 'text.secondary';
78
+ };
43
79
  const toggleCase = (item, itemKey) => {
44
80
  // Use the fully-qualified path key when available so nested case toggles are unique.
45
81
  const resolvedItemKey = itemKey || item.path || item.id;
@@ -87,6 +123,25 @@ const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPref
87
123
  const itemPath = fullRelativePath
88
124
  ? `/cases/${currentRootCaseId}/${fullRelativePath}`
89
125
  : `/cases/${currentRootCaseId}`;
126
+ const getIconForType = (type) => {
127
+ switch (type) {
128
+ case 'case':
129
+ return _jsx(BookRounded, { fontSize: "small" });
130
+ case 'observable':
131
+ return _jsx(Visibility, { fontSize: "small" });
132
+ case 'hit':
133
+ return _jsx(CheckCircle, { fontSize: "small" });
134
+ case 'table':
135
+ return _jsx(TableChart, { fontSize: "small" });
136
+ case 'lead':
137
+ return _jsx(Lightbulb, { fontSize: "small" });
138
+ case 'reference':
139
+ return _jsx(LinkIcon, { fontSize: "small" });
140
+ default:
141
+ return _jsx(Article, { fontSize: "small" });
142
+ }
143
+ };
144
+ const leafColor = getItemColor(itemType, itemKey, leaf.id);
90
145
  return (_jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", pl: step * 1.5 + 1, py: 0.25, sx: [
91
146
  {
92
147
  cursor: 'pointer',
@@ -108,7 +163,7 @@ const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPref
108
163
  transition: theme.transitions.create('transform', { duration: 100 }),
109
164
  transform: isCaseOpen ? 'rotate(90deg)' : 'rotate(0deg)'
110
165
  }
111
- ] }), isCase ? _jsx(BookRounded, { fontSize: "small" }) : _jsx(Article, { fontSize: "small" }), _jsx(Typography, { variant: "caption", color: "textSecondary", sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: last(leaf.path?.split('/') || []) })] }), isCase && isCaseOpen && isCaseLoading && (_jsx(Stack, { pl: step * 1.5 + 4, py: 0.25, children: _jsx(Skeleton, { width: 140, height: 16 }) })), isCase && isCaseOpen && nestedCase && (_jsx(CaseFolder, { case: nestedCase, step: step + 1, rootCaseId: currentRootCaseId, pathPrefix: fullRelativePath }))] }, `${_case?.case_id}-${leaf.id}-${leaf.path}`));
166
+ ] }), getIconForType(itemType), _jsx(Typography, { variant: "caption", color: leafColor, sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: last(leaf.path?.split('/') || []) })] }), isCase && isCaseOpen && isCaseLoading && (_jsx(Stack, { pl: step * 1.5 + 4, py: 0.25, children: _jsx(Skeleton, { width: 140, height: 16 }) })), isCase && isCaseOpen && nestedCase && (_jsx(CaseFolder, { case: nestedCase, step: step + 1, rootCaseId: currentRootCaseId, pathPrefix: fullRelativePath }))] }, `${_case?.case_id}-${leaf.id}-${leaf.path}`));
112
167
  })] }))] }));
113
168
  };
114
169
  export default CaseFolder;
package/package.json CHANGED
@@ -101,7 +101,7 @@
101
101
  "internal-slot": "1.0.7"
102
102
  },
103
103
  "type": "module",
104
- "version": "2.17.0-dev.513",
104
+ "version": "2.17.0-dev.514",
105
105
  "exports": {
106
106
  "./i18n": "./i18n.js",
107
107
  "./index.css": "./index.css",