Skip to content

Commit 4c37cb5

Browse files
Revert "Refactor JSONEditor and UploadFilesModal components for improved type safety and UI consistency"
This reverts commit f22859e.
1 parent f22859e commit 4c37cb5

15 files changed

Lines changed: 1433 additions & 1424 deletions

File tree

src/ContentProcessorWeb/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
"dependencies": {
77
"@azure/msal-browser": "^5.6.2",
88
"@azure/msal-react": "^5.2.0",
9+
"@fluentui/react-button": "^9.8.0",
910
"@fluentui/react-components": "^9.73.6",
11+
"@fluentui/react-dialog": "^9.16.6",
1012
"@fluentui/react-icons": "^2.0.245",
1113
"@reduxjs/toolkit": "^2.11.2",
14+
"axios": "^1.14.0",
1215
"babel-preset-react-app": "^10.1.0",
1316
"contentprocessor_web": "file:",
1417
"cra-template-typescript": "1.3.0",
@@ -58,14 +61,12 @@
5861
"@testing-library/react": "^16.3.2",
5962
"@testing-library/user-event": "^14.6.1",
6063
"@types/jest": "^30.0.0",
61-
"@types/node": "^22.15.0",
6264
"@types/react": "^19.2.14",
6365
"@types/react-dom": "^19.2.3",
6466
"@types/react-router-dom": "^5.3.3",
6567
"@types/react-virtualized": "^9.22.3",
6668
"@types/react-window": "^2.0.0",
6769
"customize-cra": "^1.0.0",
68-
"eslint": "^8.57.0",
6970
"gh-pages": "^6.3.0",
7071
"globals": "^17.4.0",
7172
"husky": "^9.1.7",
@@ -74,7 +75,7 @@
7475
"react-tiff": "^0.0.16",
7576
"sass": "^1.98.0",
7677
"sass-loader": "^16.0.7",
77-
"typescript": "^5.8.3",
78+
"typescript": "^6.0.2",
7879
"typescript-eslint": "^8.58.0"
7980
},
8081
"compilerOptions": {
@@ -101,9 +102,10 @@
101102
"postcss": "^8.5.6",
102103
"nth-check": "^2.1.1",
103104
"string_decoder": "^1.3.0",
104-
"typescript": "^5.8.3",
105+
"typescript": "^4.9.5",
105106
"node-forge": "^1.4.0",
106107
"@tootallnate/once": "^3.0.1",
108+
"axios": "^1.15.0",
107109
"brace-expansion": "^2.0.3",
108110
"flatted": "^3.4.2",
109111
"immutable": "^5.1.5",

src/ContentProcessorWeb/pnpm-lock.yaml

Lines changed: 1376 additions & 1370 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ContentProcessorWeb/src/Components/JSONEditor/JSONEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const JSONEditor: React.FC<JSONEditorProps> = () => {
4747
if (Object.keys(store.contentData).length > 0) {
4848
const formattedJson = store.contentData.result;
4949
const data = {
50-
...(formattedJson as Record<string, unknown>)
50+
...formattedJson
5151
}
5252
setJsonData(data);
5353
} else {
@@ -116,7 +116,7 @@ const JSONEditor: React.FC<JSONEditorProps> = () => {
116116
}
117117
}]}
118118
onUpdate={({ newData }) => {
119-
onUpdateHandle(newData as Record<string, unknown>)
119+
onUpdateHandle(newData)
120120
}}
121121
restrictDelete={true}
122122
showIconTooltips={true}

src/ContentProcessorWeb/src/Components/UploadContent/UploadFilesModal.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import React, { useState, useRef, useEffect } from "react";
1111
import {
1212
Dialog,
1313
DialogSurface,
14-
DialogBody,
1514
DialogTitle,
1615
DialogContent,
1716
DialogActions,
18-
Button,
17+
} from "@fluentui/react-dialog";
18+
import { Button } from "@fluentui/react-button";
19+
import {
1920
ProgressBar,
2021
makeStyles,
2122
Combobox,
@@ -342,9 +343,8 @@ const UploadFilesModal: React.FC<UploadFilesModalProps> = ({ open, onClose }) =>
342343
onClose();
343344
};
344345
return (
345-
<Dialog open={open} modalType="modal" >
346+
<Dialog open={open} modalType="alert" >
346347
<DialogSurface className={styles.dialogSurface}>
347-
<DialogBody style={{ display: "flex", flexDirection: "column", overflow: "hidden", flex: 1 }}>
348348
<DialogTitle>Import Content</DialogTitle>
349349
<DialogContent className={styles.dialogContent}>
350350
<div className="dialogBody">
@@ -439,7 +439,6 @@ const UploadFilesModal: React.FC<UploadFilesModalProps> = ({ open, onClose }) =>
439439
{uploading ? "Importing..." : "Import"}
440440
</Button>
441441
</DialogActions>
442-
</DialogBody>
443442
</DialogSurface>
444443
</Dialog>
445444
);

src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/CustomCellRender.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ const CellRenderer: React.FC<CellRendererProps> = ({ type, props }) => {
167167
<MenuItem
168168
icon={<DeleteIcon />}
169169
onClick={() => {
170-
setSelectedDeleteItem?.(item);
171-
toggleDialog?.();
170+
setSelectedDeleteItem(item);
171+
toggleDialog();
172172
}}
173173
style={{ maxWidth: 'auto', minWidth: 'auto' }}
174174
>
@@ -190,11 +190,11 @@ const CellRenderer: React.FC<CellRendererProps> = ({ type, props }) => {
190190
case 'schemaScore':
191191
return calculateSchemaScore(valueText || '', lastModifiedBy || '', status || '');
192192
case 'text':
193-
return renderText(text ?? '', 'center');
193+
return renderText(text, 'center');
194194
case 'date':
195-
return renderText(text ?? '', 'date');
195+
return renderText(text, 'date');
196196
case 'deleteButton':
197-
return item ? renderDeleteButton(item, deleteBtnStatus || { disabled: false, message: '' }) : <div>Invalid Type</div>;
197+
return renderDeleteButton(item, deleteBtnStatus || {});
198198
default:
199199
return <div>Invalid Type</div>;
200200
}

src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGrid.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const ProcessQueueGrid: React.FC<GridComponentProps> = () => {
8888
useEffect(() => {
8989
if (!store.gridLoader) {
9090
if (store.gridData.items && store.gridData.items.length > 0) {
91-
const claimRows: ClaimRowData[] = (store.gridData.items as unknown as ClaimItem[]).map((item: ClaimItem) => ({
91+
const claimRows: ClaimRowData[] = store.gridData.items.map((item: ClaimItem) => ({
9292
claim: item,
9393
isExpanded: false,
9494
isSelected: false,
@@ -113,7 +113,7 @@ const ProcessQueueGrid: React.FC<GridComponentProps> = () => {
113113
setSelectedDocumentId(null);
114114
dispatch(
115115
setSelectedClaim({
116-
claim: firstClaim as unknown as Record<string, unknown>,
116+
claim: firstClaim,
117117
})
118118
);
119119
}
@@ -149,7 +149,7 @@ const ProcessQueueGrid: React.FC<GridComponentProps> = () => {
149149
// Dispatch the claim selection
150150
dispatch(
151151
setSelectedClaim({
152-
claim: claim as unknown as Record<string, unknown>,
152+
claim: claim,
153153
})
154154
);
155155
};
@@ -160,7 +160,7 @@ const ProcessQueueGrid: React.FC<GridComponentProps> = () => {
160160
dispatch(
161161
setSelectedGridRow({
162162
processId: document.process_id,
163-
item: document as unknown as Record<string, unknown>,
163+
item: document,
164164
})
165165
);
166166
};

src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGridTypes.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* data structures (claims, documents, grid rows).
77
*/
88

9-
import type { JSX } from "react";
109
import { TableRowData as RowStateBase } from "@fluentui/react-components";
10+
import { ListChildComponentProps } from "react-window";
1111

1212
/** A single processed document within a claim batch. */
1313
export interface ProcessedDocument {
@@ -95,5 +95,11 @@ export interface TableRowData extends RowStateBase<Item> {
9595
appearance: "brand" | "none";
9696
}
9797

98+
export interface ReactWindowRenderFnProps extends ListChildComponentProps {
99+
data: TableRowData[];
100+
style: React.CSSProperties;
101+
index: number;
102+
}
103+
98104
/** Props for the {@link ProcessQueueGrid} component. */
99105
export type GridComponentProps = Record<string, never>;

src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessSteps/ProcessSteps.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,15 @@ const ProcessSteps: React.FC = () => {
9292

9393
return (
9494
<Accordion collapsible>
95-
{!status.includes(store.selectedItem.status as string) && store.processStepsData?.map((step, index) => {
96-
const stepName = step.step_name as string;
97-
const processedTime = step.processed_time as string;
98-
return (
99-
<AccordionItem key={index} value={stepName}>
95+
{!status.includes(store.selectedItem.status) && store.processStepsData?.map((step, index) => (
96+
<AccordionItem key={index} value={step.step_name}>
10097
<AccordionHeader onClick={() => handleExpand(index)}> {loadingStates[index] && <Spinner size="tiny" style={{ position: 'absolute', left: '10px' }} label="" />}
101-
<span style={{ fontWeight: 'bold', textTransform: 'capitalize'}}>{stepName}</span>
98+
<span style={{ fontWeight: 'bold', textTransform: 'capitalize'}}>{step.step_name}</span>
10299
<span style={{ color: 'green', marginLeft: 'auto', display: 'flex', alignItems: 'center' }}>
103-
{renderProcessTimeInSeconds(processedTime)} <CheckmarkCircleFilled style={{ marginLeft: '4px' }} />
100+
{renderProcessTimeInSeconds(step.processed_time)} <CheckmarkCircleFilled style={{ marginLeft: '4px' }} />
104101
</span>
105102
</AccordionHeader>
106-
<div ref={(el) => { childRefs.current[index] = el; }}>
103+
<div ref={(el) => (childRefs.current[index] = el)}>
107104
<AccordionPanel >
108105
<JsonEditor
109106
key={`json-editor-${index}`}
@@ -112,7 +109,7 @@ const ProcessSteps: React.FC = () => {
112109
restrictEdit={true}
113110
restrictDelete={true}
114111
restrictAdd={true}
115-
rootName={stepName.toLowerCase()}
112+
rootName={step.step_name.toLowerCase()}
116113
collapseAnimationTime={300}
117114
theme={[{
118115
styles: {
@@ -129,8 +126,7 @@ const ProcessSteps: React.FC = () => {
129126
</AccordionPanel>
130127
</div>
131128
</AccordionItem>
132-
);
133-
})}
129+
))}
134130
</Accordion>
135131

136132
);

src/ContentProcessorWeb/src/Pages/DefaultPage/PanelCenter.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const ChevronDoubleLeft = bundleIcon(ChevronDoubleLeft20Regular, ChevronDoubleLe
4747
/** Props for the {@link PanelCenter} component. */
4848
interface PanelCenterProps {
4949
/** Callback to collapse/expand a named panel. */
50-
readonly togglePanel: (panel: 'Left' | 'Right' | 'Center' | 'All') => void;
50+
readonly togglePanel: (panel: string) => void;
5151
}
5252

5353
const useStyles = makeStyles({
@@ -153,7 +153,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
153153
);
154154

155155
useEffect(() => {
156-
dispatch(setActiveProcessId(store.processId ?? ''))
156+
dispatch(setActiveProcessId(store.processId))
157157
setComment('');
158158
// Reset tab to appropriate default when selection changes
159159
if (store.selectionType === 'claim') {
@@ -183,7 +183,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
183183
}
184184
}
185185
// Only fetch for document selection
186-
if (store.selectionType === 'document' && (store.activeProcessId != null || store.activeProcessId !== '') && !status.includes(store.selectedItem.status as string) && store.selectedItem?.process_id === store.activeProcessId) {
186+
if (store.selectionType === 'document' && (store.activeProcessId != null || store.activeProcessId !== '') && !status.includes(store.selectedItem.status) && store.selectedItem?.process_id === store.activeProcessId) {
187187
fetchContent();
188188
}
189189
}, [store.activeProcessId, store.selectedItem, store.selectionType, store.refreshTrigger])
@@ -192,14 +192,14 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
192192
useEffect(() => {
193193
if (store.selectionType === 'claim' && store.selectedClaim?.id) {
194194
setClaimComment('');
195-
dispatch(fetchClaimDetails({ claimId: store.selectedClaim.id as string }));
195+
dispatch(fetchClaimDetails({ claimId: store.selectedClaim.id }));
196196
}
197197
}, [store.selectionType, store.selectedClaim?.id, dispatch, store.refreshTrigger])
198198

199199
// Sync claim comment with API response
200200
useEffect(() => {
201-
if ((store.claimDetails?.data as Record<string, unknown>)?.process_comment !== undefined) {
202-
setClaimComment((store.claimDetails?.data as Record<string, unknown>)?.process_comment as string || '');
201+
if (store.claimDetails?.data?.process_comment !== undefined) {
202+
setClaimComment(store.claimDetails.data.process_comment || '');
203203
}
204204
}, [store.claimDetails])
205205

@@ -232,7 +232,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
232232
<div style={{ marginBottom: '16px' }}>
233233
<h4 style={{ margin: '0 0 8px 0', color: tokens.colorNeutralForeground1 }}>Summary</h4>
234234
<p style={{ margin: 0, color: tokens.colorNeutralForeground2, whiteSpace: 'pre-wrap' }}>
235-
{(store.claimDetails.data as Record<string, unknown>)?.process_summary as string || 'No summary available'}
235+
{store.claimDetails.data.process_summary || 'No summary available'}
236236
</p>
237237
</div>
238238
</div>
@@ -266,7 +266,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
266266

267267
const ExtractedResults = React.useCallback(() => (
268268
<div role="tabpanel" className={styles.tabItemCotnent} aria-labelledby="Extracted Results">
269-
{store.activeProcessId && !status.includes(store.selectedItem.status as string) ? (
269+
{store.activeProcessId && !status.includes(store.selectedItem.status) ? (
270270
<JSONEditor
271271
processId={store.activeProcessId}
272272
/>
@@ -277,7 +277,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
277277
const ProcessHistory = useCallback(() => (
278278
<div role="tabpanel" className={styles.processTabItemCotnent} aria-labelledby="Process Steps">
279279
{apiLoader ? <div className={styles.apiLoader}><p>Loading...</p></div>
280-
: (store.processStepsData?.length === 0 || status.includes(store.selectedItem.status as string)) ? <p style={{ textAlign: 'center' }}> No data available</p>
280+
: (store.processStepsData?.length === 0 || status.includes(store.selectedItem.status)) ? <p style={{ textAlign: 'center' }}> No data available</p>
281281
: <ProcessSteps />
282282
}
283283
</div>
@@ -291,7 +291,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
291291
try {
292292
dispatch(startLoader("1"));
293293
dispatch(setUpdateComments(comment))
294-
const result = await dispatch(saveContentJson({ 'processId': store.activeProcessId, 'contentJson': store.modified_result as unknown as string, 'comments': comment, 'savedComments': store.comments }))
294+
const result = await dispatch(saveContentJson({ 'processId': store.activeProcessId, 'contentJson': store.modified_result, 'comments': comment, 'savedComments': store.comments }))
295295
if (result?.type === 'SaveContentJSON-Comments/fulfilled') {
296296
dispatch(setRefreshGrid(true));
297297
}
@@ -304,7 +304,7 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
304304

305305
const isButtonSaveDisabledCheck = () => {
306306
if(!store.activeProcessId) return true;
307-
if (status.includes(store.selectedItem.status as string)) return true;
307+
if (status.includes(store.selectedItem.status)) return true;
308308
if (Object.keys(store.modified_result).length > 0) return false;
309309
if (comment.trim() !== store.comments && comment.trim() !== '') return false;
310310
if (store.comments !== '' && comment.trim() === '') return false;
@@ -314,15 +314,15 @@ const PanelCenter: React.FC<PanelCenterProps> = ({ togglePanel }) => {
314314
const isClaimSaveDisabled = () => {
315315
if (!store.claimDetails) return true;
316316
if (store.claimCommentSaving) return true;
317-
const savedComment = ((store.claimDetails?.data as Record<string, unknown>)?.process_comment as string) || '';
317+
const savedComment = store.claimDetails?.data?.process_comment || '';
318318
// Enable save if comment has changed
319319
if (claimComment.trim() !== savedComment) return false;
320320
return true;
321321
}
322322

323323
const handleClaimSave = async () => {
324324
if (store.selectedClaim?.id) {
325-
await dispatch(saveClaimComment({ claimId: store.selectedClaim.id as string, comment: claimComment }));
325+
await dispatch(saveClaimComment({ claimId: store.selectedClaim.id, comment: claimComment }));
326326
}
327327
}
328328

src/ContentProcessorWeb/src/Pages/DefaultPage/PanelLeft.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ChevronDoubleLeft = bundleIcon(ChevronDoubleLeft20Regular, ChevronDoubleLe
2727
/** Props for the {@link PanelLeft} component. */
2828
interface PanelLeftProps {
2929
/** Callback to collapse/expand a named panel. */
30-
readonly togglePanel: (panel: 'Left' | 'Right' | 'Center' | 'All') => void;
30+
readonly togglePanel: (panel: string) => void;
3131
}
3232

3333
/**

0 commit comments

Comments
 (0)