mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-14 13:48:00 -05:00
Fix OCR screen
This commit is contained in:
parent
03364f2741
commit
cf8601072b
1 changed files with 15 additions and 17 deletions
|
@ -14,6 +14,18 @@ const ExperimentalOCR: React.FC = () => {
|
||||||
const [saving, setSaving] = useState(false); // New state for saving
|
const [saving, setSaving] = useState(false); // New state for saving
|
||||||
const [documentDetails, setDocumentDetails] = useState<Document | null>(null); // New state for document details
|
const [documentDetails, setDocumentDetails] = useState<Document | null>(null); // New state for document details
|
||||||
|
|
||||||
|
const fetchDocumentDetails = useCallback(async () => {
|
||||||
|
if (!documentId) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await axios.get<Document>(`/api/documents/${documentId}`);
|
||||||
|
setDocumentDetails(response.data);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error fetching document details:", err);
|
||||||
|
setError("Failed to fetch document details.");
|
||||||
|
}
|
||||||
|
}, [documentId]);
|
||||||
|
|
||||||
const submitOCRJob = async () => {
|
const submitOCRJob = async () => {
|
||||||
setStatus('');
|
setStatus('');
|
||||||
setError('');
|
setError('');
|
||||||
|
@ -22,6 +34,9 @@ const ExperimentalOCR: React.FC = () => {
|
||||||
setPagesDone(0); // Reset pages done
|
setPagesDone(0); // Reset pages done
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setStatus('Fetching document details...');
|
||||||
|
await fetchDocumentDetails(); // Fetch document details before submitting the job
|
||||||
|
|
||||||
setStatus('Submitting OCR job...');
|
setStatus('Submitting OCR job...');
|
||||||
const response = await axios.post(`/api/documents/${documentId}/ocr`);
|
const response = await axios.post(`/api/documents/${documentId}/ocr`);
|
||||||
setJobId(response.data.job_id);
|
setJobId(response.data.job_id);
|
||||||
|
@ -80,23 +95,6 @@ const ExperimentalOCR: React.FC = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchDocumentDetails = useCallback(async () => {
|
|
||||||
if (!documentId) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await axios.get<Document>(`/api/documents/${documentId}`);
|
|
||||||
setDocumentDetails(response.data);
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Error fetching document details:", err);
|
|
||||||
setError("Failed to fetch document details.");
|
|
||||||
}
|
|
||||||
}, [documentId]);
|
|
||||||
|
|
||||||
// Fetch document details when documentId changes
|
|
||||||
useEffect(() => {
|
|
||||||
fetchDocumentDetails();
|
|
||||||
}, [documentId, fetchDocumentDetails]);
|
|
||||||
|
|
||||||
// Start checking job status when jobId is set
|
// Start checking job status when jobId is set
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (jobId) {
|
if (jobId) {
|
||||||
|
|
Loading…
Reference in a new issue