Skip to content

Commit cc98f48

Browse files
committed
Add Firebase emulator support and debug panel for document reprocessing; remove unused formatDocumentData.js
1 parent 63f08c7 commit cc98f48

File tree

5 files changed

+189
-236
lines changed

5 files changed

+189
-236
lines changed

frontend/src/components/DocumentProcessingStatus.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,27 @@ const DocumentProcessingStatus: React.FC<DocumentProcessingStatusProps> = ({ onP
274274
</button>
275275
)}
276276

277+
{process.env.NODE_ENV === 'development' && (
278+
<div style={styles.debugPanel}>
279+
<h3>Debug Panel</h3>
280+
<button
281+
onClick={() => {
282+
const functions = getFunctions();
283+
const reprocessDocuments = httpsCallable(functions, 'reprocessDocuments');
284+
setStatus('Force reprocessing documents...');
285+
reprocessDocuments({}).then(result => {
286+
setStatus(`Reprocessing complete: ${JSON.stringify((result.data as any).stats)}`);
287+
}).catch(err => {
288+
setError(`Reprocessing failed: ${err.message}`);
289+
});
290+
}}
291+
style={styles.debugButton}
292+
>
293+
Force Reprocess Documents
294+
</button>
295+
</div>
296+
)}
297+
277298
{documents.length > 0 && (
278299
<div style={styles.documentsList}>
279300
<h3>Document Details</h3>
@@ -335,6 +356,23 @@ const DocumentProcessingStatus: React.FC<DocumentProcessingStatusProps> = ({ onP
335356
};
336357

337358
const styles = {
359+
debugPanel: {
360+
backgroundColor: '#f8f9fa',
361+
padding: '15px',
362+
marginBottom: '20px',
363+
borderRadius: '4px',
364+
border: '1px solid #dee2e6'
365+
},
366+
debugButton: {
367+
backgroundColor: '#dc3545',
368+
color: 'white',
369+
border: 'none',
370+
padding: '8px 16px',
371+
borderRadius: '4px',
372+
cursor: 'pointer',
373+
fontSize: '14px',
374+
marginTop: '10px'
375+
},
338376
container: {
339377
padding: '20px',
340378
backgroundColor: '#f9f9f9',

frontend/src/firebase/config.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { initializeApp } from 'firebase/app';
2-
import { getAuth } from 'firebase/auth';
3-
import { getFunctions } from 'firebase/functions';
2+
import { getAuth, connectAuthEmulator } from 'firebase/auth';
3+
import { getFunctions, connectFunctionsEmulator } from 'firebase/functions';
4+
import { getFirestore, connectFirestoreEmulator } from 'firebase/firestore';
5+
import { getStorage, connectStorageEmulator } from 'firebase/storage';
46

57
const firebaseConfig = {
68
apiKey: "AIzaSyBCStWgpFwe5aTJvZO1V1t_dIG3NOxfYts",
@@ -13,6 +15,18 @@ const firebaseConfig = {
1315
// Initialize Firebase
1416
const app = initializeApp(firebaseConfig);
1517

16-
// Get Auth instance
18+
// Get service instances
1719
export const auth = getAuth(app);
1820
export const functions = getFunctions(app);
21+
export const firestore = getFirestore(app);
22+
export const storage = getStorage(app);
23+
24+
// Connect to emulators in development mode
25+
if (process.env.NODE_ENV === 'development') {
26+
// Use { disableWarnings: true } to prevent the "running in emulator mode" banner
27+
connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true });
28+
connectFunctionsEmulator(functions, 'localhost', 5001);
29+
connectFirestoreEmulator(firestore, 'localhost', 8080);
30+
connectStorageEmulator(storage, 'localhost', 9199);
31+
console.log('Using Firebase emulators');
32+
}

functions-node/formatDocumentData.js

Lines changed: 0 additions & 211 deletions
This file was deleted.

0 commit comments

Comments
 (0)