diff --git a/src/api/neutralizationApi.ts b/src/api/neutralizationApi.ts index 6bf799b..a153fbd 100644 --- a/src/api/neutralizationApi.ts +++ b/src/api/neutralizationApi.ts @@ -25,6 +25,7 @@ export interface NeutralizationConfig { export interface NeutralizationResult { neutralized_text?: string; + neutralized_bytes?: string | Uint8Array; neutralized_file_base64?: string; neutralized_file_name?: string; mime_type?: string; diff --git a/src/pages/views/neutralization/NeutralizationView.tsx b/src/pages/views/neutralization/NeutralizationView.tsx index d4d5a66..dd4d94a 100644 --- a/src/pages/views/neutralization/NeutralizationView.tsx +++ b/src/pages/views/neutralization/NeutralizationView.tsx @@ -2,14 +2,15 @@ * NeutralizationView * * Combined view for the Neutralization feature with two tabs: - * - Configuration: Enable/disable neutralization, configure names to parse, SharePoint paths. - * - Playground: Manual text neutralization and placeholder resolution. + * - Configuration: Configure names to parse. + * - Playground: Upload file, paste text, or neutralize SharePoint files. Resolve placeholders. */ import React, { useState, useEffect, useCallback } from 'react'; import { useCurrentInstance } from '../../../hooks/useCurrentInstance'; import { useToast } from '../../../contexts/ToastContext'; import { useFileContext } from '../../../contexts/FileContext'; +import { useConnections, type Connection } from '../../../hooks/useConnections'; import { getNeutralizationConfig, saveNeutralizationConfig, @@ -20,8 +21,26 @@ import { type NeutralizationConfig, } from '../../../api/neutralizationApi'; import { Tabs } from '../../../components/UiComponents/Tabs'; +import api from '../../../api'; import styles from './NeutralizationViews.module.css'; +interface SiteOption { + value: string; + label: string; + siteId: string; + siteName: string; + webUrl: string; + path: string; +} + +interface FolderOption { + value: string; + label: string; + siteId: string; + folderName: string; + path: string; +} + // ============================================================================= // CONFIGURATION TAB // ============================================================================= @@ -33,13 +52,10 @@ const ConfigTab: React.FC = () => { const [config, setConfig] = useState(null); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); - const [processing, setProcessing] = useState(false); const [error, setError] = useState(null); const [enabled, setEnabled] = useState(true); const [namesToParse, setNamesToParse] = useState(''); - const [sharepointSourcePath, setSharepointSourcePath] = useState(''); - const [sharepointTargetPath, setSharepointTargetPath] = useState(''); const loadConfig = useCallback(async () => { setLoading(true); @@ -49,8 +65,6 @@ const ConfigTab: React.FC = () => { setConfig(data); setEnabled(data.enabled); setNamesToParse(data.namesToParse || ''); - setSharepointSourcePath(data.sharepointSourcePath || ''); - setSharepointTargetPath(data.sharepointTargetPath || ''); } catch (err: unknown) { const errObj = err as { response?: { data?: { detail?: string | { msg?: string }[] } }; message?: string }; const detail = errObj.response?.data?.detail; @@ -85,8 +99,8 @@ const ConfigTab: React.FC = () => { userId: config?.userId || '', enabled, namesToParse, - sharepointSourcePath, - sharepointTargetPath, + sharepointSourcePath: config?.sharepointSourcePath || '', + sharepointTargetPath: config?.sharepointTargetPath || '', }); showSuccess('Saved', 'Configuration saved successfully.'); await loadConfig(); @@ -103,34 +117,6 @@ const ConfigTab: React.FC = () => { } }; - const handleProcessSharepoint = async () => { - if (!sharepointSourcePath.trim() || !sharepointTargetPath.trim()) { - showError('Error', 'Both SharePoint source and target paths are required.'); - return; - } - setProcessing(true); - setError(null); - try { - const result = await processSharepointFiles(sharepointSourcePath, sharepointTargetPath); - if (result.success) { - showSuccess('Done', result.message || 'SharePoint files processed successfully.'); - } else { - setError(result.message || 'Processing failed'); - showError('Error', result.message || 'Processing failed'); - } - } catch (err: unknown) { - const errObj = err as { response?: { data?: { detail?: string } }; message?: string }; - const message = - (typeof errObj.response?.data?.detail === 'string' ? errObj.response.data.detail : null) || - errObj.message || - 'Failed to process SharePoint files'; - setError(message); - showError('Error', message); - } finally { - setProcessing(false); - } - }; - const dismissError = () => setError(null); if (loading) { @@ -154,18 +140,6 @@ const ConfigTab: React.FC = () => { )} -
-
- setEnabled(e.target.checked)} - /> - -
-
-